Browse Source

Import upstream version 1.4.0

James Cameron 10 years ago
parent
commit
2f11e614b9
55 changed files with 4555 additions and 4984 deletions
  1. 0 12
      BUGS
  2. 21 21
      COPYING
  3. 32 0
      ChangeLog
  4. 0 196
      ChangeLog-0.8
  5. 0 130
      ChangeLog-0.9
  6. 0 21
      ChangeLog-1.1.3
  7. 5 5
      Makefile.am
  8. 357 207
      Makefile.in
  9. 6 6
      Makefile.uClinux
  10. 13 0
      NEWS
  11. 0 88
      PROTOCOL-SECURITY
  12. 4 0
      README.cvs
  13. 0 91
      RELEASING
  14. 0 2
      acconfig.h
  15. 295 174
      aclocal.m4
  16. 19 15
      bcrelay.c
  17. 0 11
      build.sh
  18. 48 44
      compat.c
  19. 10 12
      compat.h
  20. 0 2
      config.embed.h
  21. 0 2
      config.h.in
  22. 99 101
      configfile.c
  23. 1 3
      configfile.h
  24. 561 424
      configure
  25. 1 1
      configure.in
  26. 412 417
      ctrlpacket.c
  27. 6 8
      ctrlpacket.h
  28. 7 0
      debian/changelog
  29. 0 1
      debian/crontab.ex
  30. 0 1
      debian/diversions.ex
  31. 0 2
      debian/inetd.conf.ex
  32. 0 15
      debian/info.ex
  33. 0 5
      debian/watch.ex
  34. 32 34
      defaults.h
  35. 449 451
      getopt.c
  36. 58 60
      getopt1.c
  37. 27 29
      inststr.c
  38. 1 3
      inststr.h
  39. 15 17
      our_getopt.h
  40. 7 9
      our_syslog.h
  41. 38 40
      ppphdlc.c
  42. 3 5
      ppphdlc.h
  43. 559 561
      pptpctrl.c
  44. 1 3
      pptpctrl.h
  45. 562 558
      pptpd.c
  46. 1 1
      pptpd.spec
  47. 190 192
      pptpdefs.h
  48. 396 397
      pptpgre.c
  49. 4 6
      pptpgre.h
  50. 291 293
      pptpmanager.c
  51. 1 3
      pptpmanager.h
  52. 23 22
      pqueue.c
  53. 0 196
      tools/client-test
  54. 0 42
      tools/confmod.sh
  55. 0 45
      tools/vpnwho.pl

+ 0 - 12
BUGS

@@ -1,12 +0,0 @@
-Review of Debian bugs
-
-171831: requires significant redesign, in TODO as item 19990705
-	(upstream acknowledges and has added it to the list)
-
-181005: requires code change, added to TODO as item 20030214
-	(upstream acknowledges and has added it to the list)
-        (ip_gre module is not needed at all, comment made)
-        (the GRE response is an acknowledgement packet)
-
-209082: debian project's problem, not upstream
-

+ 21 - 21
COPYING

@@ -1,12 +1,12 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
 
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          675 Mass Ave, Cambridge, MA 02139, USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-			    Preamble
+                            Preamble
 
   The licenses for most software are designed to take away your
 freedom to share and change it.  By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users.  This
 General Public License applies to most of the Free Software
 Foundation's software and to any other program whose authors commit to
 using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
+the GNU Lesser General Public License instead.)  You can apply it to
 your programs, too.
 
   When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
 
   The precise terms and conditions for copying, distribution and
 modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
+
+                    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
     License.  (Exception: if the Program itself is interactive but
     does not normally print such an announcement, your work based on
     the Program is not required to print an announcement.)
-
+
 These requirements apply to the modified work as a whole.  If
 identifiable sections of that work are not derived from the Program,
 and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
 access to copy the source code from the same place counts as
 distribution of the source code, even though third parties are not
 compelled to copy the source along with the object code.
-
+
   4. You may not copy, modify, sublicense, or distribute the Program
 except as expressly provided under this License.  Any attempt
 otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
 
 This section is intended to make thoroughly clear what is believed to
 be a consequence of the rest of this License.
-
+
   8. If the distribution and/or use of the Program is restricted in
 certain countries either by patents or by copyrighted interfaces, the
 original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this.  Our decision will be guided by the two goals
 of preserving the free status of all derivatives of our free software and
 of promoting the sharing and reuse of software generally.
 
-			    NO WARRANTY
+                            NO WARRANTY
 
   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
-		     END OF TERMS AND CONDITIONS
-
-	Appendix: How to Apply These Terms to Your New Programs
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
 the "copyright" line and a pointer to where the full notice is found.
 
     <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
+    Copyright (C) <year>  <name of author>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -303,16 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 Also add information on how to contact you by electronic and paper mail.
 
 If the program is interactive, make it output a short notice like this
 when it starts in an interactive mode:
 
-    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision version 69, Copyright (C) year name of author
     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     This is free software, and you are welcome to redistribute it
     under certain conditions; type `show c' for details.
@@ -335,5 +335,5 @@ necessary.  Here is a sample; alter the names:
 This General Public License does not permit incorporating your program into
 proprietary programs.  If your program is a subroutine library, you may
 consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
+library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.

+ 32 - 0
ChangeLog

@@ -1,3 +1,35 @@
+Wed Oct 23 16:23:58 2013  James Cameron  <quozl@laptop.org>
+
+	* pptpd-1.4.0.tar.gz: released.
+
+Mon Oct 21 20:50:07 2013  John Lauro  <john.lauro@covenanteyes.com>
+
+	* pqueue.c: don't leak memory from duplicate packet.
+
+	* pptpgre.c, pptpmanager.c: don't leak handle on connect fail and
+	detect error on socket creation instead later.
+
+	* bcrelay.c: code cleanup - warning fix.
+
+	* ctrlpacket.c, ctrlpacket.h, pptpctrl.c: clean up warning
+	dereferecing type-punned pointer from mixing struct and unsigned
+	char.
+
+	* ctrlpacket.c, pptpgre.c: fix several warnings in newer
+	compilers, caused by format and type discrepancies.
+
+	* ctrlpacket.c, ctrlpacket.h: use unsigned types to properly
+	handle negative error codes.
+
+	* bcrelay.c: code cleanup (potential off by one error, bcrelay),
+	switch a copy function to strncpy, as original had a potential off
+	by one error as the size check didn't account for trailing 0 to be
+	added in next line.
+
+	* bcrelay.c: fix several warnings in newer compilers, caused by
+	format and type discrepancies, and comparing with == directly to
+	"", as "" is not guaranteed to always be the same when redefined.
+
 Thu Feb  7 11:51:46 2013  James Cameron  <quozl@laptop.org>
 
 	* plugins/pptpd-logwtmp.c: use pppd.h provided by ppp package

+ 0 - 196
ChangeLog-0.8

@@ -1,196 +0,0 @@
-PoPToP ChangeLog
-
----------------------------------------------------------------------------
-v0.8.13 -> v0.9.0
-11th June, 1999
-
-- possibly fixed the 'error 629 on startup' bug.  this fix is incompatible
-  with the 'silent' option of pppd, so don't use the 'silent' option.
-- support a single localip with a range of remoteip's
-- new, small, fast, simple get_call_id() function
-- removed a few hardcoded values in ctrlpacket and replaced with defines
-- new pptp_read_header() - slightly more 'expensive' but should be much more
-  robust
-- use openpty() if possible, internalize tty opening, startCall much more
-  simple
-
----------------------------------------------------------------------------
-v0.8.12 -> v0.8.13
-10th June, 1999
-
-- removed ctrl-manager pipe completely
-- moved awareness of pppd-ip-alloc option to manager only
-- if using pppd-ip-alloc, manager runs more efficiently
-- made pptpctrl able to have a none, one or both of local/remote addresses
-  rather than only both or none
-- great code simplicication
-- re-did IP parser; less potential segfaults from bad config
-- correctly calculate max connections based on number of IP addresses given
-  and statically configured maximum
-- no max connections for the pppd-ip-alloc case
-- properly permit hostnames in IP parser
-- always use fd 0 for network connection
-- fixed -c option
-- note - this version changes the 'run from inetd' options.  re-read
-  README.inetd if you use it
-
----------------------------------------------------------------------------
-v0.8.11 -> v0.8.12
-8th June, 1999
-
-- made autoconf actually check the relevant headers
-- made config.embed.h and removed most #if EMBED in favour of using this
-- fixed some includes and re-arranged things to be a bit cleaner
-- minor cosmetic fixes
-- fixed compilation on StarOS 4 (and hence SunOS 4)
-- documentation on running from ientd
-- removed ctrl-manager pipe by default
-
----------------------------------------------------------------------------
-v0.8.10 -> v0.8.11
-8th June, 1999
-
-- now only two executables, pptpd and pptpctrl
-- re-did dependency generation
-- minor include cleanups
-
----------------------------------------------------------------------------
-v0.8.9 -> v0.8.10
-8th June, 1999
-
-- added getopt_long() from GNU libc for use on non-Linux platforms
-- fixed compilation on FreeBSD, Digital Unix and Solaris
-- replaced PPTPD_DEBUG define with configuration option (debug) and
-  command line option (-d/--debug)
-
----------------------------------------------------------------------------
-v0.8.8 -> v0.8.9
-7th June, 1999
-
-- unified CTRL and GRE processes (removed pptpgre), without the vfork
-  problem since this is not forking
-- changed process name for child processes to pptpd [ip.address.here]
-- moved INTERNAL_IP_ALLOCATION to a configure option (see configure --help)
-- added support for libwrap tcp wrappers
-- made sure pppd doesn't get copies of file descriptors it shouldn't, so
-  it closes down properly
-- lots of other misc fixes
-
----------------------------------------------------------------------------
-v0.8.7 -> v0.8.8
-4th June, 1999
-
-- increased MAX number of clients to 100
-- layout and comments have been tidied up extensively throughout code
-- new function in ctrlpacket.c for making Control Message headers
-- openBSD fixes
-- many other minor bug fixes
-- some portability issues addressed
-- accept() moved into pptpmanager.
-- pptpmanager closes one side of socketpair server fd and passes client fd
-    other side of socketpair to pptpctrl.
-- pptpmanager main loop changed to select without timeout and made to
-    watch ALL appropriate file descriptors.
-- also made resiliant against some potential error modes, eg, if we are
-    full don't select on new connections descriptor, if accept() fails
-    ignore it cleanly, etc.
-- should be more 'resource friendly' now.
-- Make error state filename instead of just CONFIG FILE: file not found.
-- Limit packet size to PACKET_MAX instead of permitting 4 more if no ACK
-    is bundled (for consistency of packet size limit).
-
----------------------------------------------------------------------------
-v0.8.6 -> v0.8.7
-1st June, 1999
-
-- GRE seperated from pptpctrl to support vforking
-- adds link status detection (ie if a link goes down, we can figure it out
-    and deal with it) (Kevin)
-- Solaris/Slirp port (Harald Vogt)
-- cleaned up comments a lot (move towards C style to permit compiling in 
-    older compilers/increase portablity)
-- standardized #ifndef #define #endif defines in header files
-- stop inststr from nuking environment (hopefully)
-- use longer argv[0] in exec()s to make inststr much nicer
-- make inststr wipe args other than argv[0]
-- #define to remove some debugging (PPTPD_DEBUG) and to remove the
-    IP address allocation code so PPPD can be used to allocate IP addresses
-    (INTERNAL_IP_ALLOCATION)
-- in pptpctrl.c, main()'s addrlen was uninitialized - yuck, was causing
-    random variable overwriting
-- clean up some wasteful memory copying and so on, as well as remove some
-    copies into small static buffers
-- clean up some blank lines - increasing the amount of code visible one
-    screen is good if it can be done without making the formatting ugly.
-- use exit() not _exit() in pptpd - the fear of this closing fork()d
-    filedescriptors is wrong.  both have the same file descriptor closing
-    properties.
-- remove a potential leak of 2 filedescriptors in option parsing (checks
-    of optional file names).
-- miscellaneous EMBED support for syslog etc.
-- many other misc changes.
-
----------------------------------------------------------------------------
-v0.8.5 -> v0.8.6
-21st May 1999
-
-- added new ip address reading from config file (for multiple connections)
-    there is a new pptpd configuration file example in samples/
-- pptpdebug.* is no longer... syslog now handles ALL debugging
-
----------------------------------------------------------------------------
-v0.8.4 -> v0.8.5
-18th May 1999
-
-- command line args/config file options are broken (everything hardcoded)
-- many, many, many structural changes for a multiple connection hack
-- multiple connection support
-- reconnect support
-- OpenBSD port (may be broken for this release... Peter?)
-- logging now to syslog DAEMON|DEBUG
-
----------------------------------------------------------------------------
-v0.8.3 -> v0.8.4
-13th May 1999
-
-- call_id/peer_id issues addressed in OUT_CALL packets
-- bug in debug log time fixed
-- local added by default to the pppd launcher
-- call_disconnect_notify bug fixed
-- -p command line arg broken
-
----------------------------------------------------------------------------
-v0.8.2 -> v0.8.3
-11th May 1999
-
-- a few minor multiple connection hacks.. still nowhere near ready to
-    handle more than one client
-- pptpd -p logfile bug fix
-
----------------------------------------------------------------------------
-v0.8.1 -> v0.8.2
-11th May 1999
-
-- Server will no longer die if client disconnects
-- pppd is closed down cleanly now
-- autoconf/automake is back.. but still needs some work
-- a number of minor CTRL establishment bugs fixed
-- callid assignment modified slightly in manager
-
----------------------------------------------------------------------------
-v0.8.0 -> v0.8.1
-4th May 1999
-
-- PPTPD no longer relies on a signal (which had the potential to cause
-    a race condition) to know when to launch PPPD/GRE. The CTRL session
-    no longer relies on a signal to return from a fork. Signalling has
-    now been replaced with IPC between PPTPD and CTRL sessions.
-- The GRE/PPPD sessions are now launched *after* an OUT_CALL_RPLY is sent
-    not before it.
-- CTRL and PPTP managers are now seperate from PPTPD
-
----------------------------------------------------------------------------
-v0.8.0
-30th April 1999
-
-PoPToP now works with windows 95/98/NT and Linux clients.

+ 0 - 130
ChangeLog-0.9

@@ -1,130 +0,0 @@
-PoPToP ChangeLog
-
----------------------------------------------------------------------------
-v0.9.12 -> v0.9.13
-17 August, 1999
-
-- added pptpd.8
-- added pptpd.conf.5
-
----------------------------------------------------------------------------
-v0.9.11 -> v0.9.12
-16 August, 1999
-
-- hand fixed bug in Makefile.in to work around automake bug (distdir
-  target)
-- made 'make dist' work
-- added pptpctrl.8
-- added HOWTO/FAQ to html/ and removed old docs
-
----------------------------------------------------------------------------
-v0.9.10 -> v0.9.11
-8 August, 1999
-
-- increased "receive window size" to match the other side
-- improved behaviour if a network write ever fails
-- minor changes to macro names and operation of functions
-- check call id on incoming GRE packets
-
----------------------------------------------------------------------------
-v0.9.9 -> v0.9.10
-2 August, 1999
-
-- keep a pid file - /var/run/pptpd.pid by default, overriden by config
-  option pidfile or commandline option -p/--pidfile
-- added another TODO item
-
----------------------------------------------------------------------------
-v0.9.8 -> v0.9.9
-29 July, 1999
-
-- move libutil.h to after sys/types.h (FreeBSD 3.1)
-- add option file passing to SLIRP
-- reduce the number of variables used for option parsing/storage
-- add option to set local address to bind to ("listen")
-- configure script forces pppd ip allocation when needed, rather than
-  exiting on an error
-
----------------------------------------------------------------------------
-v0.9.7 -> v0.9.8
-26 July, 1999
-
-- zero sockaddr_in (to blank out sin_len on BSD)
-- include libutil.h if there is one for openpty() proto (FreeBSD)
-- attempt to continue after failed bind() (OpenBSD?)
-
----------------------------------------------------------------------------
-v0.9.6 -> v0.9.7
-22 July, 1999
-
-- added doc for setting up MPPE
-- use error names rather than numbers where easily possible
-
----------------------------------------------------------------------------
-v0.9.5 -> v0.9.6
-15 July, 1999
-
-- moved binaries to /usr/local/sbin (ie, configure's --sbindir)
-- some documentation fixes
-- big warning about having to delete old /usr/local/sbin/pptp{d,ctrl,...}
-
----------------------------------------------------------------------------
-v0.9.4 -> v0.9.5
-7 July, 1999
-
-- bad sequence number message made to detect duplicates and out of order
-  and report appropriately
-- show if libwrap is selected in configure script output
-- completely re-did connection termination to match draft spec (unfortunately
-  generates a warning when talking to Win98) 
-- changed capabilities to be more realistic
-- fixed echo reply processing (should prevent death when idle)
-- made call id handling more sane
-- made us always use the right call id in the right place
-- print errno on GRE write failures
-- bind GRE to address connection was received on
-
----------------------------------------------------------------------------
-v0.9.3 -> v0.9.4
-5 July, 1999
-
-- fixed to detect Slackware 4.0 needing -lintl for gettext()
-- better fix for using different binary locations (cover --bindir too)
-- removed select() in ctrlpacket.c in favour of setting control sockets
-  to be nonblocking (for performance - plain read() is cheaper than
-  select() especially when you're pretty sure of success)
-
----------------------------------------------------------------------------
-v0.9.2 -> v0.9.3
-2 July, 1999
-
-- changes to configure to fix SLIRP option and print out options chosen
-- configure --prefix fix
-
----------------------------------------------------------------------------
-v0.9.1 -> v0.9.2
-17th June, 1999
-
-- made usage info not show details which aren't relevant to current config
-- made configure force pppd-ip-alloc on systems where we don't yet support
-  passing IP addresses to pppd (SLIRP, BSDUSER_PPP)
-- minor slirp fix for pppd startup detection
-
----------------------------------------------------------------------------
-v0.9.0 -> v0.9.1
-17th June, 1999
-
-- made a few minor changes for slirp
-- added macros for PPTP packet creation and removed memcpy() where simple
-  assignment is sufficient; CPU usage should be lower
-- cleaned up call_id to always be passed around as a network byte order
-  u_int16_t
-- added some missing ntoh32() in pptpgre.c (currently no effect as ack_recv
-  is ignored)
-- speedups in GRE routines
-- no longer close stderr (fd 2) in pptpctrl.c to overcome problems where
-  syslog() is absent
-- increased debugging in openpty()
-
----------------------------------------------------------------------------
-

+ 0 - 21
ChangeLog-1.1.3

@@ -1,21 +0,0 @@
-poptop (1.1.3-3) unstable; urgency=low
-
-  * v1.1.3-3
-  * Added stimeout option to pptpd.conf manpage
-  * Updated the Changelog file
-
-   -- R. de Vroede <richard@oip.tudelft.nl>  Thu, Aug 22 2002 11:34:05 +0200
-
-  * v1.1.3-2
-  * Removed debug commandline option from pptpd.init
-
-   -- R. de Vroede <richard@oip.tudelft.nl>  Tue, Aug 20 2002 11:34:05 +0200
-
-  * v1.1.3-1
-  * added config(noreplace) so old configs don't get replaced
-  * Fixed postscriptlet
-  * Adapted RPM specfile to cvs tree
-  * RPM specfile now supports --with[out] options
-
-   -- R. de Vroede <richard@oip.tudelft.nl>  Thu, Aug  1 2002 11:34:05 +0200
-

+ 5 - 5
Makefile.am

@@ -83,7 +83,7 @@ compat.o: compat.c config.h compat.h our_syslog.h inststr.h
 configfile.o: configfile.c config.h defaults.h configfile.h our_syslog.h
 
 ctrlpacket.o: ctrlpacket.c config.h our_syslog.h pptpdefs.h pptpctrl.h \
-  ctrlpacket.h compat.h
+ ctrlpacket.h compat.h
 
 getopt.o: getopt.c config.h our_getopt.h
 
@@ -94,16 +94,16 @@ inststr.o: inststr.c config.h inststr.h compat.h
 ppphdlc.o: ppphdlc.c config.h ppphdlc.h
 
 pptpctrl.o: pptpctrl.c config.h our_syslog.h compat.h pptpctrl.h \
-  pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
+ pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
 
 pptpd.o: pptpd.c config.h our_syslog.h our_getopt.h configfile.h \
-  defaults.h compat.h pptpmanager.h
+ defaults.h compat.h pptpmanager.h
 
 pptpgre.o: pptpgre.c config.h our_syslog.h ppphdlc.h pptpgre.h pptpdefs.h \
-  pptpctrl.h defaults.h pqueue.h compat.h
+ pptpctrl.h defaults.h pqueue.h compat.h
 
 pptpmanager.o: pptpmanager.c config.h our_syslog.h configfile.h \
-  defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
+ defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
 
 pqueue.o: pqueue.c pqueue.h
 

+ 357 - 207
Makefile.in

@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,15 +15,29 @@
 
 @SET_MAKE@
 
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
 VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = .
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
 install_sh_SCRIPT = $(install_sh) -c
@@ -46,13 +61,13 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno configure.status.lineno
+ configure.lineno config.status.lineno
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" \
 	"$(DESTDIR)$(man8dir)"
-sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(sbin_PROGRAMS)
 am_bcrelay_OBJECTS = bcrelay.$(OBJEXT)
 bcrelay_OBJECTS = $(am_bcrelay_OBJECTS)
@@ -68,7 +83,7 @@ am_pptpd_OBJECTS = pqueue.$(OBJEXT) pptpd.$(OBJEXT) \
 	inststr.$(OBJEXT) getopt.$(OBJEXT) getopt1.$(OBJEXT)
 pptpd_OBJECTS = $(am_pptpd_OBJECTS)
 pptpd_DEPENDENCIES = $(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
+DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
 am__depfiles_maybe =
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -77,6 +92,38 @@ CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(bcrelay_SOURCES) $(pptpctrl_SOURCES) $(pptpd_SOURCES)
 DIST_SOURCES = $(bcrelay_SOURCES) $(pptpctrl_SOURCES) $(pptpd_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 man5dir = $(mandir)/man5
 man8dir = $(mandir)/man8
 NROFF = nroff
@@ -87,16 +134,18 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
 am__remove_distdir = \
-  { test ! -d $(distdir) \
-    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
-         && rm -fr $(distdir); }; }
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
 distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
 distcleancheck_listfiles = find . -type f -print
 ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -117,6 +166,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 GREP = @GREP@
 HAVE_OPENPTY = @HAVE_OPENPTY@
+INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -127,6 +177,7 @@ LIBS = @LIBS@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -144,9 +195,11 @@ VERSION = @VERSION@
 XTRALIBS_CTRL = @XTRALIBS_CTRL@
 XTRALIBS_MGR = @XTRALIBS_MGR@
 XTRA_PROG = @XTRA_PROG@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
@@ -154,6 +207,7 @@ am__tar = @am__tar@
 am__untar = @am__untar@
 bindir = @bindir@
 build_alias = @build_alias@
+builddir = @builddir@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
@@ -177,15 +231,19 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
 
 # We have our own, simpler dependencies stuff in 'reconf'
 AUTOMAKE_OPTIONS = no-dependencies foreign
 INCLUDES = -I.
 #CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"'
 #CFLAGS = -O2 -fno-builtin -Wall -ansi -pedantic -Wmissing-prototypes -Werror -DSBINDIR='"$(sbindir)"'
-man_MANS = pptpctrl.8 pptpd.8 pptpd.conf.5
+man_MANS = pptpctrl.8 pptpd.8 pptpd.conf.5 bcrelay.8
 EXTRA_DIST = \
 html README* ChangeLog NEWS TODO $(man_MANS) \
 samples/chap-secrets samples/options.pptpd samples/pptpd.conf \
@@ -220,21 +278,21 @@ all: config.h
 
 .SUFFIXES:
 .SUFFIXES: .c .o .obj
-am--refresh:
+am--refresh: Makefile
 	@:
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
-	      cd $(srcdir) && $(AUTOMAKE) --foreign  \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
 		&& exit 0; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -250,21 +308,20 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENC
 	$(SHELL) ./config.status --recheck
 
 $(top_srcdir)/configure:  $(am__configure_deps)
-	cd $(srcdir) && $(AUTOCONF)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@if test ! -f $@; then \
-	  rm -f stamp-h1; \
-	  $(MAKE) stamp-h1; \
-	else :; fi
+	@if test ! -f $@; then rm -f stamp-h1; else :; fi
+	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status config.h
 $(srcdir)/config.h.in:  $(am__configure_deps) $(top_srcdir)/acconfig.h
-	cd $(top_srcdir) && $(AUTOHEADER)
+	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
 
@@ -272,36 +329,53 @@ distclean-hdr:
 	-rm -f config.h stamp-h1
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
-	test -z "$(sbindir)" || $(mkdir_p) "$(DESTDIR)$(sbindir)"
-	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
+	fi; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	      echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
+	      $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(sbindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(sbindir)/$$f"; \
-	done
+	@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(sbindir)" && rm -f $$files
 
 clean-sbinPROGRAMS:
 	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-bcrelay$(EXEEXT): $(bcrelay_OBJECTS) $(bcrelay_DEPENDENCIES) 
+bcrelay$(EXEEXT): $(bcrelay_OBJECTS) $(bcrelay_DEPENDENCIES) $(EXTRA_bcrelay_DEPENDENCIES) 
 	@rm -f bcrelay$(EXEEXT)
-	$(LINK) $(bcrelay_LDFLAGS) $(bcrelay_OBJECTS) $(bcrelay_LDADD) $(LIBS)
-pptpctrl$(EXEEXT): $(pptpctrl_OBJECTS) $(pptpctrl_DEPENDENCIES) 
+	$(LINK) $(bcrelay_OBJECTS) $(bcrelay_LDADD) $(LIBS)
+pptpctrl$(EXEEXT): $(pptpctrl_OBJECTS) $(pptpctrl_DEPENDENCIES) $(EXTRA_pptpctrl_DEPENDENCIES) 
 	@rm -f pptpctrl$(EXEEXT)
-	$(LINK) $(pptpctrl_LDFLAGS) $(pptpctrl_OBJECTS) $(pptpctrl_LDADD) $(LIBS)
-pptpd$(EXEEXT): $(pptpd_OBJECTS) $(pptpd_DEPENDENCIES) 
+	$(LINK) $(pptpctrl_OBJECTS) $(pptpctrl_LDADD) $(LIBS)
+pptpd$(EXEEXT): $(pptpd_OBJECTS) $(pptpd_DEPENDENCIES) $(EXTRA_pptpd_DEPENDENCIES) 
 	@rm -f pptpd$(EXEEXT)
-	$(LINK) $(pptpd_LDFLAGS) $(pptpd_OBJECTS) $(pptpd_LDADD) $(LIBS)
+	$(LINK) $(pptpd_OBJECTS) $(pptpd_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -314,188 +388,215 @@ distclean-compile:
 
 .c.obj:
 	$(COMPILE) -c `$(CYGPATH_W) '$<'`
-uninstall-info-am:
-install-man5: $(man5_MANS) $(man_MANS)
+install-man5: $(man_MANS)
 	@$(NORMAL_INSTALL)
-	test -z "$(man5dir)" || $(mkdir_p) "$(DESTDIR)$(man5dir)"
-	@list='$(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS)'; \
-	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-	for i in $$l2; do \
-	  case "$$i" in \
-	    *.5*) list="$$list $$i" ;; \
-	  esac; \
+	@list1=''; \
+	list2='$(man_MANS)'; \
+	test -n "$(man5dir)" \
+	  && test -n "`echo $$list1$$list2`" \
+	  || exit 0; \
+	echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
+	$(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
+	{ for i in $$list1; do echo "$$i"; done;  \
+	if test -n "$$list2"; then \
+	  for i in $$list2; do echo "$$i"; done \
+	    | sed -n '/\.5[a-z]*$$/p'; \
+	fi; \
+	} | while read p; do \
+	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; echo "$$p"; \
+	done | \
+	sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+	sed 'N;N;s,\n, ,g' | { \
+	list=; while read file base inst; do \
+	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
+	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
+	  fi; \
 	done; \
-	for i in $$list; do \
-	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
-	  else file=$$i; fi; \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  case "$$ext" in \
-	    5*) ;; \
-	    *) ext='5' ;; \
-	  esac; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
-	  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst"; \
-	done
+	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+	while read files; do \
+	  test -z "$$files" || { \
+	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
+	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
+	done; }
+
 uninstall-man5:
 	@$(NORMAL_UNINSTALL)
-	@list='$(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS)'; \
-	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-	for i in $$l2; do \
-	  case "$$i" in \
-	    *.5*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  case "$$ext" in \
-	    5*) ;; \
-	    *) ext='5' ;; \
-	  esac; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " rm -f '$(DESTDIR)$(man5dir)/$$inst'"; \
-	  rm -f "$(DESTDIR)$(man5dir)/$$inst"; \
-	done
-install-man8: $(man8_MANS) $(man_MANS)
+	@list=''; test -n "$(man5dir)" || exit 0; \
+	files=`{ for i in $$list; do echo "$$i"; done; \
+	l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+	  sed -n '/\.5[a-z]*$$/p'; \
+	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+	dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
+install-man8: $(man_MANS)
 	@$(NORMAL_INSTALL)
-	test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)"
-	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
-	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-	for i in $$l2; do \
-	  case "$$i" in \
-	    *.8*) list="$$list $$i" ;; \
-	  esac; \
+	@list1=''; \
+	list2='$(man_MANS)'; \
+	test -n "$(man8dir)" \
+	  && test -n "`echo $$list1$$list2`" \
+	  || exit 0; \
+	echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
+	$(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
+	{ for i in $$list1; do echo "$$i"; done;  \
+	if test -n "$$list2"; then \
+	  for i in $$list2; do echo "$$i"; done \
+	    | sed -n '/\.8[a-z]*$$/p'; \
+	fi; \
+	} | while read p; do \
+	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; echo "$$p"; \
+	done | \
+	sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+	sed 'N;N;s,\n, ,g' | { \
+	list=; while read file base inst; do \
+	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
+	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
+	  fi; \
 	done; \
-	for i in $$list; do \
-	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
-	  else file=$$i; fi; \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  case "$$ext" in \
-	    8*) ;; \
-	    *) ext='8' ;; \
-	  esac; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
-	  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst"; \
-	done
+	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+	while read files; do \
+	  test -z "$$files" || { \
+	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
+	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
+	done; }
+
 uninstall-man8:
 	@$(NORMAL_UNINSTALL)
-	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
-	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-	for i in $$l2; do \
-	  case "$$i" in \
-	    *.8*) list="$$list $$i" ;; \
-	  esac; \
-	done; \
-	for i in $$list; do \
-	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-	  case "$$ext" in \
-	    8*) ;; \
-	    *) ext='8' ;; \
-	  esac; \
-	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " rm -f '$(DESTDIR)$(man8dir)/$$inst'"; \
-	  rm -f "$(DESTDIR)$(man8dir)/$$inst"; \
-	done
+	@list=''; test -n "$(man8dir)" || exit 0; \
+	files=`{ for i in $$list; do echo "$$i"; done; \
+	l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+	  sed -n '/\.8[a-z]*$$/p'; \
+	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+	dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
+	@list='$(MANS)'; if test -n "$$list"; then \
+	  list=`for p in $$list; do \
+	    if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+	    if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+	  if test -n "$$list" && \
+	    grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+	    echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+	    grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+	    echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+	    echo "       typically \`make maintainer-clean' will remove them" >&2; \
+	    exit 1; \
+	  else :; fi; \
+	else :; fi
 	$(am__remove_distdir)
-	mkdir $(distdir)
-	$(mkdir_p) $(distdir)/debian $(distdir)/debian/po $(distdir)/plugins $(distdir)/samples $(distdir)/tools
-	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-	list='$(DISTFILES)'; for file in $$list; do \
-	  case $$file in \
-	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-	  esac; \
+	test -d "$(distdir)" || mkdir "$(distdir)"
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-	    dir="/$$dir"; \
-	    $(mkdir_p) "$(distdir)$$dir"; \
-	  else \
-	    dir=''; \
-	  fi; \
 	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
-	-find "$(distdir)" -type d ! -perm -755 \
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -755 \
 		-exec chmod u+rwx,go+rx {} \; -o \
 	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
-	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
-	|| chmod -R a+r $(distdir)
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
 	$(am__remove_distdir)
 
 dist-bzip2: distdir
-	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+	$(am__remove_distdir)
+
+dist-lzip: distdir
+	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+	$(am__remove_distdir)
+
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
+
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
 	$(am__remove_distdir)
 
 dist-tarZ: distdir
@@ -521,24 +622,33 @@ dist dist-all: distdir
 distcheck: dist
 	case '$(DIST_ARCHIVES)' in \
 	*.tar.gz*) \
-	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
-	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lzma*) \
+	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.lz*) \
+	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
-	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	chmod -R a-w $(distdir); chmod u+w $(distdir)
 	mkdir $(distdir)/_build
 	mkdir $(distdir)/_inst
 	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
-	  && cd $(distdir)/_build \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build \
 	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
@@ -559,14 +669,24 @@ distcheck: dist
 	  && rm -rf "$$dc_destdir" \
 	  && $(MAKE) $(AM_MAKEFLAGS) dist \
 	  && rm -rf $(DIST_ARCHIVES) \
-	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
 	$(am__remove_distdir)
 	@(echo "$(distdir) archives ready for distribution: "; \
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
-	  sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
 distuninstallcheck:
-	@cd $(distuninstallcheck_dir) \
-	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	@test -n '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: trying to run $@ with an empty' \
+	       '$$(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	$(am__cd) '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
 	   || { echo "ERROR: files left after uninstall:" ; \
 	        if test -n "$(DESTDIR)"; then \
 	          echo "  (check DESTDIR support)"; \
@@ -587,7 +707,7 @@ check: check-am
 all-am: Makefile $(PROGRAMS) $(MANS) config.h all-local
 installdirs:
 	for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"; do \
-	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
 install-exec: install-exec-am
@@ -599,16 +719,22 @@ install-am: all-am
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -629,18 +755,38 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
 
 install-data-am: install-man
 
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
 install-exec-am: install-exec-local install-sbinPROGRAMS
 
+install-html: install-html-am
+
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man: install-man5 install-man8
 
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -661,26 +807,29 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-info-am uninstall-local uninstall-man \
-	uninstall-sbinPROGRAMS
+uninstall-am: uninstall-local uninstall-man uninstall-sbinPROGRAMS
 
 uninstall-man: uninstall-man5 uninstall-man8
 
+.MAKE: all install-am install-strip
+
 .PHONY: CTAGS GTAGS all all-am all-local am--refresh check check-am \
 	clean clean-generic clean-local clean-sbinPROGRAMS ctags dist \
-	dist-all dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip \
-	distcheck distclean distclean-compile distclean-generic \
-	distclean-hdr distclean-tags distcleancheck distdir \
-	distuninstallcheck dvi dvi-am html html-am info info-am \
-	install install-am install-data install-data-am install-exec \
-	install-exec-am install-exec-local install-info \
-	install-info-am install-man install-man5 install-man8 \
-	install-sbinPROGRAMS install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+	dist-all dist-bzip2 dist-gzip dist-lzip dist-lzma dist-shar \
+	dist-tarZ dist-xz dist-zip distcheck distclean \
+	distclean-compile distclean-generic distclean-hdr \
+	distclean-tags distcleancheck distdir distuninstallcheck dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-exec-local install-html \
+	install-html-am install-info install-info-am install-man \
+	install-man5 install-man8 install-pdf install-pdf-am \
+	install-ps install-ps-am install-sbinPROGRAMS install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-info-am uninstall-local uninstall-man \
-	uninstall-man5 uninstall-man8 uninstall-sbinPROGRAMS
+	uninstall-am uninstall-local uninstall-man uninstall-man5 \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 
 @SET_MAKE@
@@ -714,7 +863,7 @@ compat.o: compat.c config.h compat.h our_syslog.h inststr.h
 configfile.o: configfile.c config.h defaults.h configfile.h our_syslog.h
 
 ctrlpacket.o: ctrlpacket.c config.h our_syslog.h pptpdefs.h pptpctrl.h \
-  ctrlpacket.h compat.h
+ ctrlpacket.h compat.h
 
 getopt.o: getopt.c config.h our_getopt.h
 
@@ -725,18 +874,19 @@ inststr.o: inststr.c config.h inststr.h compat.h
 ppphdlc.o: ppphdlc.c config.h ppphdlc.h
 
 pptpctrl.o: pptpctrl.c config.h our_syslog.h compat.h pptpctrl.h \
-  pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
+ pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
 
 pptpd.o: pptpd.c config.h our_syslog.h our_getopt.h configfile.h \
-  defaults.h compat.h pptpmanager.h
+ defaults.h compat.h pptpmanager.h
 
 pptpgre.o: pptpgre.c config.h our_syslog.h ppphdlc.h pptpgre.h pptpdefs.h \
-  pptpctrl.h defaults.h pqueue.h compat.h
+ pptpctrl.h defaults.h pqueue.h compat.h
 
 pptpmanager.o: pptpmanager.c config.h our_syslog.h configfile.h \
-  defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
+ defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
 
 pqueue.o: pqueue.c pqueue.h
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

+ 6 - 6
Makefile.uClinux

@@ -39,10 +39,10 @@ bcrelay.o: bcrelay.c config.embed.h defaults.h our_syslog.h our_getopt.h
 compat.o: compat.c config.embed.h compat.h our_syslog.h inststr.h
 
 configfile.o: configfile.c config.embed.h defaults.h configfile.h \
-  our_syslog.h
+ our_syslog.h
 
 ctrlpacket.o: ctrlpacket.c config.embed.h our_syslog.h pptpdefs.h \
-  pptpctrl.h ctrlpacket.h compat.h
+ pptpctrl.h ctrlpacket.h compat.h
 
 getopt.o: getopt.c config.embed.h our_getopt.h
 
@@ -53,16 +53,16 @@ inststr.o: inststr.c config.embed.h inststr.h compat.h
 ppphdlc.o: ppphdlc.c config.embed.h ppphdlc.h
 
 pptpctrl.o: pptpctrl.c config.embed.h our_syslog.h compat.h pptpctrl.h \
-  pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
+ pptpgre.h pptpdefs.h ctrlpacket.h defaults.h
 
 pptpd.o: pptpd.c config.embed.h our_syslog.h our_getopt.h configfile.h \
-  defaults.h compat.h pptpmanager.h
+ defaults.h compat.h pptpmanager.h
 
 pptpgre.o: pptpgre.c config.embed.h our_syslog.h ppphdlc.h pptpgre.h \
-  pptpdefs.h pptpctrl.h defaults.h pqueue.h compat.h
+ pptpdefs.h pptpctrl.h defaults.h pqueue.h compat.h
 
 pptpmanager.o: pptpmanager.c config.embed.h our_syslog.h configfile.h \
-  defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
+ defaults.h pptpctrl.h pptpdefs.h pptpmanager.h compat.h
 
 pqueue.o: pqueue.c config.embed.h pqueue.h
 

+ 13 - 0
NEWS

@@ -1,3 +1,16 @@
+1.4.0: released 2013-10-23
+
+- change GPL license FSF addresses [Cameron]
+- clean up unused return value warnings [Cameron]
+- don't leak memory on duplicate packet [Lauro]
+- clean up several compiler warnings [Lauro]
+- use pppd.h from ppp-dev [Teasdale]
+- do not drop connection on ENOBUFS [Curia]
+- fix binary trash when launching pppd [tevaum]
+- add remotenumber support [Tarasov / Poetters]
+- catch missing EOL at EOF [Biedl]
+- add bcrelay manual page [Trong]
+- fix segfault on invalid IP range [Naumov]
 - add support for VRFs through libvrf [Lamparter]
 - fix implementation of IDLE_WAIT [Douglass]
 - fix compilation with uclibc with legacy support disabled [Hiramoto]

+ 0 - 88
PROTOCOL-SECURITY

@@ -1,88 +0,0 @@
-
-   Protocol Security
-
-   Summary
-
-                                                         by Peter Mueller
-
-   PPTP is known to be a faulty protocol. The designers of the protocol,
-   Microsoft, recommend not to use it due to the inherent risks. Lots of
-   people use PPTP anyway due to ease of use, but that doesn't mean it is
-   any less hazardous. The maintainers of PPTP Client and Poptop
-   recommend using OpenVPN (SSL based) or IPSec instead.
-
-   (Posted on [1]2005-08-10 to the [2]mailing list)
-     _________________________________________________________________
-
-   Why not use PPTP?
-
-                                                         by James Cameron
-
-   The point to point tunneling protocol (PPTP) is not secure enough for
-   some information security policies.
-
-   It's the nature of the MSCHAP V2 authentication, how it can be broken
-   trivially by capture of the datastream, and how MPPE depends on the
-   MSCHAP tokens for cryptographic keys. MPPE is also only 128-bit,
-   reasonably straightforward to attack, and the keys used at each end
-   are the same, which lowers the effort required to succeed. The obvious
-   lack of two-factor authentication, instead relying on a single
-   username and password, is also a risk. The increasing use of domestic
-   wireless systems makes information capture more likely.
-
-   However, that doesn't mean people don't accept the risks. There are
-   many corporations and individuals using PPTP with full knowledge of
-   these risks. Some use mitigating controls, and some don't.
-
-   Many people seem to judge the security of a protocol by the
-   availability of the implementation, the ease of installation, or the
-   level of documentation on our web site. Improving the documentation is
-   the purpose of this web site, and we aren't doing that in order to say
-   anything about the risks of the software! Any judgement of security
-   should be rigorously applied to the design and implementation alone.
-
-   PPTP on Linux, and Microsoft's PPTP, both implement fixes for
-   vulnerabilities that were detected years ago in Microsoft's PPTP. But
-   there remain the design vulnerabilities that cannot be fixed without
-   changing the design. The changes needed would break interoperability.
-   We can't change the Linux PPTP design, because it would stop working
-   with Microsoft PPTP. They can't change their design, because it would
-   stop working with all the other components out there, such as Nortel
-   and Cisco, embedded routers, ADSL modems and their own Windows
-   installed base.
-
-   The only option then is to deprecate the product and promote the
-   replacement. Microsoft promote something else. Our choice for Open
-   Source systems is OpenVPN or IPsec.
-
-   Level of acceptance isn't a good indicator of risk either. Some have
-   said that the shipping of MSCHAP V2, MPPE and PPTP in Linux
-   distributions is an indication of design security, but that's not the
-   reason. It's for interoperability. As an example, see how Linux
-   distributions still ship telnet, ftp, and rsh, even though these
-   components are insecure because they reveal the password in cleartext
-   in the network packets. The same can be said of many other components
-   and packages.
-
-   Our recommendations are;
-
-    1. do not implement PPTP between open source systems, because there's
-       no justification, better security can be had from OpenVPN or
-       IPsec,
-
-    2. do not implement PPTP servers unless the justification is that the
-       clients must not have to install anything to get going (Microsoft
-       PPTP is included already), and be aware of the risks of
-       information interception,
-
-    3. do not implement PPTP clients unless the justification is that the
-       server only provides PPTP, and there's nothing better that can be
-       used, and again be aware of the risks of information interception.
-
-   (Posted on [3]2005-08-10 to the [2]mailing list)
-
-References
-
-   1. http://marc.theaimsgroup.com/?l=poptop-server&m=112369621702624&w=2
-   2. http://pptpclient.sourceforge.net/contact.phtml#list
-   3. http://marc.theaimsgroup.com/?l=poptop-server&m=112365342910897&w=2

+ 4 - 0
README.cvs

@@ -1,3 +1,7 @@
+20131023
+
+file obsolete after migration to git
+
 20040425
 
 a) the main CVS module "poptop" is no longer the stable version, it is

+ 0 - 91
RELEASING

@@ -1,91 +0,0 @@
-Releasing pptpd
-
-cvs update
-decide on version number
-update version number in the following files
-	pptpd.spec
-	configure.in
-	debian/changelog
-run ./reconf
-update NEWS, ChangeLog
-commit changes
-tag, see README.cvs, for example:
-	cvs tag -F pptpd-1_3_4
-make dist
-md5sum
-gpg --detach-sign --armor
-test
-
-
-Test Plan
-
-a) unpacks into subdirectory with correct package and version string,
-b) "./configure"
-c) "make" 
-d) "make install" 
-e) set configuration files for a tunnel, establish two tunnels, ping,
-   ssh, scp 10Mb random data, close tunnel, re-establish, ping, close
-   tunnels.
-f) "make uninstall"
-
-Packaging
-
-fakeroot rpmbuild -ta pptpd-1.3.4.tar.gz
-# fails
-mv /usr/src/rpm/SRPMS/pptpd-1.3.4-0.src.rpm .
-mv /usr/src/rpm/RPMS/i386/pptpd-1.3.4-0.i386.rpm .
-
-SourceForge
-
-ftp -n upload.sourceforge.net <<EOF
-user anonymous qz@hp.com
-cd incoming
-hash
-passive
-put pptpd-1.3.4.tar.gz
-put pptpd-1.3.4-0.src.rpm
-put pptpd-1.3.4-0.i386.rpm
-quit
-EOF
-http://sourceforge.net/
-Login
-Poptop
-Admin
-File Releases
-Add Release "pptpd-1.3.4 (experimental)" to package "pptpd"
-
-Announcement
-
-To: poptop-server@lists.sourceforge.net
-Subject: pptpd-1.3.4 released
-
-G'day,
-
-pptpd 1.3.4 has been released.
-
-Please reply to the mailing list with your test results.
-
-See:
-        http://sourceforge.net/projects/poptop (click on Files)
-        http://sourceforge.net/project/showfiles.php?group_id=44827
-
-Checksums:
-	b38df9c431041922c997c1148bedf591  pptpd-1.3.4.tar.gz
-
-Changes to pptpd since 1.3.3 are:
-- fix two release critical packet reordering bugs [Oester]
-- accept both types of domain delimiter [Cameron]
-- deprecate PPP_WAIT workaround in favour of turning off pty echo [Brady]
-
-See the detailed ChangeLog
-
---
-
-Cryptographically sign the mail.
-
---
-
-Update versions.inc on web site http://poptop.sourceforge.net/
-Update versions on web site http://poptop.org/ via robertw@snapgear.com
-
---

+ 0 - 2
acconfig.h

@@ -2,8 +2,6 @@
  * acconfig.h
  *
  * Additional autoconf defines for this program.
- *
- * $Id: acconfig.h,v 1.6 2005/12/29 01:21:09 quozl Exp $
  */
 
 /* Use BSD User land PPP? */

+ 295 - 174
aclocal.m4

@@ -1,7 +1,8 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+# Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -11,33 +12,63 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software
+# Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
 # generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11.6], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
 
 # AM_SET_CURRENT_AUTOMAKE_VERSION
 # -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.9.6])])
+[AM_AUTOMAKE_VERSION([1.11.6])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
@@ -85,14 +116,14 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 7
+# serial 9
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
@@ -101,8 +132,11 @@ AC_DEFUN([AM_CONDITIONAL],
 [AC_PREREQ(2.52)dnl
  ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
 	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])
-AC_SUBST([$1_FALSE])
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
 if $2; then
   $1_TRUE=
   $1_FALSE='#'
@@ -116,15 +150,14 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
+# 2010, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 8
+# serial 12
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -152,6 +185,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl
 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
                    [depcc="$$1"   am_compiler_list=])
 
@@ -163,6 +197,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.
@@ -180,6 +215,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
   if test "$am_compiler_list" = ""; then
      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
   fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
   for depmode in $am_compiler_list; do
     # Setup a source with many dependencies, because some compilers
     # like to wrap large dependency lists on column 80 (with \), and
@@ -197,7 +242,17 @@ AC_CACHE_CHECK([dependency style of $depcc],
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
     case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
     nosideeffect)
       # after this tag, mechanisms are not by side-effect, so they'll
       # only be used when explicitly requested
@@ -207,18 +262,23 @@ AC_CACHE_CHECK([dependency style of $depcc],
 	break
       fi
       ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
     none) break ;;
     esac
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.
     if depmode=$depmode \
-       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       source=sub/conftest.c object=$am__obj \
        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
          >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
       # icc doesn't choke on unknown options, it will just issue warnings
       # or remarks (even with -Werror).  So we grep stderr for any message
@@ -267,63 +327,79 @@ AC_DEFUN([AM_DEP_TRACK],
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
+  am__nodep='_no'
 fi
 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
 ])
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 3
+#serial 5
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[for mf in $CONFIG_FILES; do
-  # Strip MF so we end up with the name of the file.
-  mf=`echo "$mf" | sed -e 's/:.*$//'`
-  # Check whether this is an Automake generated Makefile or not.
-  # We used to match only the files named `Makefile.in', but
-  # some people rename them; so instead we look at the file content.
-  # Grep'ing the first line is not enough: some people post-process
-  # each Makefile.in and add a new line on top of each file to say so.
-  # So let's grep whole file.
-  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
-    dirpart=`AS_DIRNAME("$mf")`
-  else
-    continue
-  fi
-  # Extract the definition of DEPDIR, am__include, and am__quote
-  # from the Makefile without running `make'.
-  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-  test -z "$DEPDIR" && continue
-  am__include=`sed -n 's/^am__include = //p' < "$mf"`
-  test -z "am__include" && continue
-  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-  # When using ansi2knr, U may be empty or an underscore; expand it
-  U=`sed -n 's/^U = //p' < "$mf"`
-  # Find all dependency output files, they are included files with
-  # $(DEPDIR) in their names.  We invoke sed twice because it is the
-  # simplest approach to changing $(DEPDIR) to its actual value in the
-  # expansion.
-  for file in `sed -n "
-    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-    # Make sure the directory exists.
-    test -f "$dirpart/$file" && continue
-    fdir=`AS_DIRNAME(["$file"])`
-    AS_MKDIR_P([$dirpart/$fdir])
-    # echo "creating $dirpart/$file"
-    echo '# dummy' > "$dirpart/$file"
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
   done
-done
+}
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
 
@@ -354,14 +430,14 @@ AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# serial 16
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -378,16 +454,20 @@ AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
 # arguments mandatory, and then we can depend on a new Autoconf
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.58])dnl
+[AC_PREREQ([2.62])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
 AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
 AC_REQUIRE([AC_PROG_INSTALL])dnl
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
-   test -f $srcdir/config.status; then
-  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
 fi
 
 # test whether we have cygpath
@@ -407,6 +487,9 @@ m4_ifval([$2],
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
@@ -422,8 +505,8 @@ AM_MISSING_PROG(AUTOCONF, autoconf)
 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
 AM_MISSING_PROG(AUTOHEADER, autoheader)
 AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_PROG_INSTALL_SH
-AM_PROG_INSTALL_STRIP
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
 AC_REQUIRE([AM_PROG_MKDIR_P])dnl
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
@@ -431,20 +514,37 @@ AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
-              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
-	      		     [_AM_PROG_TAR([v7])])])
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-                  [_AM_DEPENDENCIES(CC)],
-                  [define([AC_PROG_CC],
-                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+		  [_AM_DEPENDENCIES(CC)],
+		  [define([AC_PROG_CC],
+			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-                  [_AM_DEPENDENCIES(CXX)],
-                  [define([AC_PROG_CXX],
-                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+		  [_AM_DEPENDENCIES(CXX)],
+		  [define([AC_PROG_CXX],
+			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+		  [_AM_DEPENDENCIES(OBJC)],
+		  [define([AC_PROG_OBJC],
+			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
 ])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 ])
 
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
 
 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
@@ -455,29 +555,40 @@ AC_PROVIDE_IFELSE([AC_PROG_CXX],
 # our stamp files there.
 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
 [# Compute $1's index in $config_headers.
+_am_arg=$1
 _am_stamp_count=1
 for _am_header in $config_headers :; do
   case $_am_header in
-    $1 | $1:* )
+    $_am_arg | $_am_arg:* )
       break ;;
     * )
       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
   esac
 done
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation,
+# Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
 AC_SUBST(install_sh)])
 
 # Copyright (C) 2003, 2005  Free Software Foundation, Inc.
@@ -503,13 +614,13 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 4
 
 # AM_MAKE_INCLUDE()
 # -----------------
@@ -518,7 +629,7 @@ AC_DEFUN([AM_MAKE_INCLUDE],
 [am_make=${MAKE-make}
 cat > confinc << 'END'
 am__doit:
-	@echo done
+	@echo this is the am__doit target
 .PHONY: am__doit
 END
 # If we don't find an include directive, just comment out the code.
@@ -528,24 +639,24 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
-   am__include=include
-   am__quote=
-   _am_result=GNU
-fi
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
 # Now try BSD make style include.
 if test "$am__include" = "#"; then
    echo '.include "confinc"' > confmf
-   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
-      am__include=.include
-      am__quote="\""
-      _am_result=BSD
-   fi
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
 fi
 AC_SUBST([am__include])
 AC_SUBST([am__quote])
@@ -555,14 +666,14 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 6
 
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
@@ -578,7 +689,15 @@ AC_SUBST($1)])
 # If it does, set am_missing_run to use it, otherwise, to nothing.
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
 # Use eval to expand $SHELL
 if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
@@ -588,78 +707,45 @@ else
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation,
+# Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_MKDIR_P
 # ---------------
-# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-#
-# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
-# created by `make install' are always world readable, even if the
-# installer happens to have an overly restrictive umask (e.g. 077).
-# This was a mistake.  There are at least two reasons why we must not
-# use `-m 0755':
-#   - it causes special bits like SGID to be ignored,
-#   - it may be too restrictive (some setups expect 775 directories).
-#
-# Do not use -m 0755 and let people choose whatever they expect by
-# setting umask.
-#
-# We cannot accept any implementation of `mkdir' that recognizes `-p'.
-# Some implementations (such as Solaris 8's) are not thread-safe: if a
-# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
-# concurrently, both version can detect that a/ is missing, but only
-# one can create it and the other will error out.  Consequently we
-# restrict ourselves to GNU make (using the --version option ensures
-# this.)
+# Check for `mkdir -p'.
 AC_DEFUN([AM_PROG_MKDIR_P],
-[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
-  # We used to keeping the `.' as first argument, in order to
-  # allow $(mkdir_p) to be used without argument.  As in
-  #   $(mkdir_p) $(somedir)
-  # where $(somedir) is conditionally defined.  However this is wrong
-  # for two reasons:
-  #  1. if the package is installed by a user who cannot write `.'
-  #     make install will fail,
-  #  2. the above comment should most certainly read
-  #     $(mkdir_p) $(DESTDIR)$(somedir)
-  #     so it does not work when $(somedir) is undefined and
-  #     $(DESTDIR) is not.
-  #  To support the latter case, we have to write
-  #     test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
-  #  so the `.' trick is pointless.
-  mkdir_p='mkdir -p --'
-else
-  # On NextStep and OpenStep, the `mkdir' command does not
-  # recognize any option.  It will interpret all options as
-  # directories to create, and then abort because `.' already
-  # exists.
-  for d in ./-p ./--version;
-  do
-    test -d $d && rmdir $d
-  done
-  # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
-  if test -f "$ac_aux_dir/mkinstalldirs"; then
-    mkdir_p='$(mkinstalldirs)'
-  else
-    mkdir_p='$(install_sh) -d'
-  fi
-fi
-AC_SUBST([mkdir_p])])
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software
+# Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 5
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -667,16 +753,16 @@ AC_DEFUN([_AM_MANGLE_OPTION],
 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
 
 # _AM_SET_OPTION(NAME)
-# ------------------------------
+# --------------------
 # Set option NAME.  Presently that only means defining a flag for this option.
 AC_DEFUN([_AM_SET_OPTION],
 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
 
 # _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
+# ------------------------
 # OPTIONS is a space-separated list of Automake options.
 AC_DEFUN([_AM_SET_OPTIONS],
-[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 
 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
 # -------------------------------------------
@@ -686,14 +772,14 @@ AC_DEFUN([_AM_IF_OPTION],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 # AM_SANITY_CHECK
 # ---------------
@@ -702,16 +788,29 @@ AC_DEFUN([AM_SANITY_CHECK],
 # Just in case
 sleep 1
 echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
    if test "$[*]" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t "$srcdir/configure" conftest.file`
    fi
    rm -f conftest.file
    if test "$[*]" != "X $srcdir/configure conftest.file" \
@@ -736,12 +835,14 @@ Check your system clock])
 fi
 AC_MSG_RESULT(yes)])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 1
+
 # AM_PROG_INSTALL_STRIP
 # ---------------------
 # One issue with vendor `install' (even GNU) is that you can't
@@ -761,12 +862,31 @@ dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
 if test "$cross_compiling" != no; then
   AC_CHECK_TOOL([STRIP], [strip], :)
 fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
+# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 3
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -788,10 +908,11 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
 # a tarball read from stdin.
 #     $(am__untar) < result.tar
 AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.
-AM_MISSING_PROG([AMTAR], [tar])
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
 m4_if([$1], [v7],
-     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
      [m4_case([$1], [ustar],, [pax],,
               [m4_fatal([Unknown tar format])])
 AC_MSG_CHECKING([how to create a $1 tar archive])

+ 19 - 15
bcrelay.c

@@ -316,8 +316,8 @@ int main(int argc, char **argv) {
 
 #ifndef BCRELAY
   fprintf(stderr,
-	  "bcrelay: pptpd was compiled without support for bcrelay, exiting.\n"
-	  "         run configure --with-bcrelay, make, and install.\n");
+          "bcrelay: pptpd was compiled without support for bcrelay, exiting.\n"
+          "         run configure --with-bcrelay, make, and install.\n");
   exit(1);
 #endif
 
@@ -399,9 +399,13 @@ int main(int argc, char **argv) {
   if (vdaemon) {
 #if HAVE_DAEMON
     closelog();
-    freopen("/dev/null", "r", stdin);
+    if (freopen("/dev/null", "r", stdin) == NULL) {
+      syslog(LOG_ERR, "failed to reopen stdin");
+    }
     /* set noclose, we want stdout/stderr still attached if we can */
-    daemon(0, 1);
+    if (daemon(0, 1) == -1) {
+      syslog_perror("daemon");
+    }
     /* returns to child only */
     /* pid will have changed */
     openlog("bcrelay", LOG_PID, PPTP_FACILITY);
@@ -426,7 +430,7 @@ static void mainloop(int argc, char **argv)
   struct iflist *iflist = NULL;         // Initialised after the 1st packet
   struct sockaddr_ll sa;
   struct packet *ipp_p;
-  char *udppdu; // FIXME: warning: pointer targets in assignment differ in signedness
+  unsigned char *udppdu;
   fd_set sock_set;
   struct timeval time_2_wait;
   static struct ifsnr old_ifsnr[MAXIF+1]; // Old iflist to socket fd's mapping list
@@ -665,16 +669,16 @@ static void mainloop(int argc, char **argv)
                  */
                 if ((nrsent = sendto(cur_ifsnr[j].sock_nr, ipp_p, rlen, MSG_DONTWAIT|MSG_TRYHARD, (struct sockaddr *)&sa, salen)) < 0)
                 {
-		  if (errno == ENETDOWN) {
-		    syslog(LOG_NOTICE, "ignored ENETDOWN from sendto(), a network interface was going down?");
-		  } else if (errno == ENXIO) {
-		    syslog(LOG_NOTICE, "ignored ENXIO from sendto(), a network interface went down?");
-		  } else if (errno == ENOBUFS) {
-		    syslog(LOG_NOTICE, "ignored ENOBUFS from sendto(), temporary shortage of buffer memory");
-		  } else {
-		    syslog(LOG_ERR, "mainloop: Error, sendto failed! (rv=%d, errno=%d)", nrsent, errno);
-		    exit(1);
-		  }
+                  if (errno == ENETDOWN) {
+                    syslog(LOG_NOTICE, "ignored ENETDOWN from sendto(), a network interface was going down?");
+                  } else if (errno == ENXIO) {
+                    syslog(LOG_NOTICE, "ignored ENXIO from sendto(), a network interface went down?");
+                  } else if (errno == ENOBUFS) {
+                    syslog(LOG_NOTICE, "ignored ENOBUFS from sendto(), temporary shortage of buffer memory");
+                  } else {
+                    syslog(LOG_ERR, "mainloop: Error, sendto failed! (rv=%d, errno=%d)", nrsent, errno);
+                    exit(1);
+                  }
                 }
                 NVBCR_PRINTF(("Successfully relayed %d bytes \n", nrsent));
                 if (vnologging == 0) {

+ 0 - 11
build.sh

@@ -1,11 +0,0 @@
-#!/bin/sh
-echo "build.sh: superceded by makepackage"
-exit 1
-
-POPTOPVERSION=`./version`
-CURRENTDIR=`pwd`
-THISDIR=${CURRENTDIR##*/}
-if [ -f /etc/redhat-release ]; then
-   tar -czf /usr/src/redhat/SOURCES/pptpd-${POPTOPVERSION}.tar.gz .
-   rpmbuild -ta /usr/src/redhat/SOURCES/pptpd-${POPTOPVERSION}.tar.gz
-fi

+ 48 - 44
compat.c

@@ -2,8 +2,6 @@
  * compat.c
  *
  * Compatibility functions for different OSes
- *
- * $Id: compat.c,v 1.6 2005/08/22 00:48:34 quozl Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -11,6 +9,7 @@
 #endif
 
 #include "compat.h"
+#include "our_syslog.h"
 
 #ifndef HAVE_STRLCPY
 #include <string.h>
@@ -18,16 +17,16 @@
 
 void strlcpy(char *dst, const char *src, size_t size)
 {
-	strncpy(dst, src, size - 1);
-	dst[size - 1] = '\0';
+        strncpy(dst, src, size - 1);
+        dst[size - 1] = '\0';
 }
 #endif
 
 #ifndef HAVE_MEMMOVE
 void *memmove(void *dst, const void *src, size_t size)
 {
-	bcopy(src, dst, size);
-	return dst;
+        bcopy(src, dst, size);
+        return dst;
 }
 #endif
 
@@ -57,49 +56,49 @@ void *memmove(void *dst, const void *src, size_t size)
 
 int openpty(int *master, int *slave, char *name, void *unused1, void *unused2)
 {
-	int devindex = 0, letter = 0;
-	int fd1, fd2;
-	char ttydev[PTYMAX], ptydev[TTYMAX];
-
-	syslog(LOG_DEBUG, "CTRL: Allocating pty/tty pair");
-	strcpy(ttydev, TTYDEV);
-	strcpy(ptydev, PTYDEV);
-	while (PTYCHAR1[letter]) {
-		ttydev[TTYMAX - 3] = ptydev[PTYMAX - 3] = PTYCHAR1[letter];
-		while (PTYCHAR2[devindex]) {
-			ttydev[TTYMAX - 2] = ptydev[PTYMAX - 2] = PTYCHAR2[devindex];
-			if ((fd1 = open(ptydev, O_RDWR)) >= 0) {
-				if ((fd2 = open(ttydev, O_RDWR)) >= 0) {
-					goto out;
-				} else {
-					close(fd1);
-				}
-			}
-			devindex++;
-		}
-		devindex = 0;
-		letter++;
-	}
-	syslog(LOG_ERR, "CTRL: Failed to allocate pty");
-	return -1;		/* Unable to allocate pty */
+        int devindex = 0, letter = 0;
+        int fd1, fd2;
+        char ttydev[PTYMAX], ptydev[TTYMAX];
+
+        syslog(LOG_DEBUG, "CTRL: Allocating pty/tty pair");
+        strcpy(ttydev, TTYDEV);
+        strcpy(ptydev, PTYDEV);
+        while (PTYCHAR1[letter]) {
+                ttydev[TTYMAX - 3] = ptydev[PTYMAX - 3] = PTYCHAR1[letter];
+                while (PTYCHAR2[devindex]) {
+                        ttydev[TTYMAX - 2] = ptydev[PTYMAX - 2] = PTYCHAR2[devindex];
+                        if ((fd1 = open(ptydev, O_RDWR)) >= 0) {
+                                if ((fd2 = open(ttydev, O_RDWR)) >= 0) {
+                                        goto out;
+                                } else {
+                                        close(fd1);
+                                }
+                        }
+                        devindex++;
+                }
+                devindex = 0;
+                letter++;
+        }
+        syslog(LOG_ERR, "CTRL: Failed to allocate pty");
+        return -1;              /* Unable to allocate pty */
 
       out:
-	syslog(LOG_INFO, "CTRL: Allocated pty/tty pair (%s,%s)", ptydev, ttydev);
-	if (master)
-		*master = fd1;
-	if (slave)
-		*slave = fd2;
-	if (name)
-		strcpy(name, ttydev);	/* no way to bounds check */
-	return 0;
+        syslog(LOG_INFO, "CTRL: Allocated pty/tty pair (%s,%s)", ptydev, ttydev);
+        if (master)
+                *master = fd1;
+        if (slave)
+                *slave = fd2;
+        if (name)
+                strcpy(name, ttydev);   /* no way to bounds check */
+        return 0;
 }
 #endif
 
 #ifndef HAVE_STRERROR
 char *strerror(int errnum) {
-	static char buf[16];
-	sprintf(buf, "Error %d", errnum);
-	return buf;
+        static char buf[16];
+        sprintf(buf, "Error %d", errnum);
+        return buf;
 }
 #endif
 
@@ -165,7 +164,9 @@ int sigpipe_create()
 /* generic handler for signals, writes signal number to pipe */
 void sigpipe_handler(int signum)
 {
-  write(sigpipe[1], &signum, sizeof(signum));
+  if (write(sigpipe[1], &signum, sizeof(signum)) == -1) {
+    syslog_perror("sigpipe write");
+  }
   signal(signum, sigpipe_handler);
 }
 
@@ -189,7 +190,10 @@ int sigpipe_fd()
 int sigpipe_read()
 {
   int signum;
-  read(sigpipe[0], &signum, sizeof(signum));
+  if (read(sigpipe[0], &signum, sizeof(signum)) == -1) {
+    syslog_perror("sigpipe read");
+    return 0;
+  }
   return signum;
 }
 

+ 10 - 12
compat.h

@@ -2,8 +2,6 @@
  * compat.h
  *
  * Compatibility functions for different OSes (prototypes)
- *
- * $Id: compat.h,v 1.5 2005/01/05 11:01:51 quozl Exp $
  */
 
 #ifndef _PPTPD_COMPAT_H
@@ -26,11 +24,11 @@
  * means we don't know how many bytes were copied
  */
 extern void strlcpy(char *dst, const char *src, size_t size);
-#endif	/* !HAVE_STRLCPY */
+#endif  /* !HAVE_STRLCPY */
 
 #ifndef HAVE_MEMMOVE
 extern void *memmove(void *dst, const void *src, size_t size);
-#endif	/* !HAVE_MEMMOVE */
+#endif  /* !HAVE_MEMMOVE */
 
 #ifndef HAVE_OPENPTY
 /* Originally from code by C. S. Ananian */
@@ -40,18 +38,18 @@ extern void *memmove(void *dst, const void *src, size_t size);
  * Note that Unix98 has an openpty() call so we don't need to worry
  * about the new pty names here.
  */
-#define PTYDEV		"/dev/ptyxx"
-#define TTYDEV		"/dev/ttyxx"
-#define PTYMAX		11
-#define TTYMAX		11
-#define PTYCHAR1	"pqrstuvwxyzabcde"
-#define PTYCHAR2	"0123456789abcdef"
+#define PTYDEV          "/dev/ptyxx"
+#define TTYDEV          "/dev/ttyxx"
+#define PTYMAX          11
+#define TTYMAX          11
+#define PTYCHAR1        "pqrstuvwxyzabcde"
+#define PTYCHAR2        "0123456789abcdef"
 
 /* Dummy the last 2 args, so we don't have to find the right include
  * files on every OS to define the needed structures.
  */
 extern int openpty(int *, int *, char *, void *, void *);
-#endif	/* !HAVE_OPENPTY */
+#endif  /* !HAVE_OPENPTY */
 
 #ifndef HAVE_STRERROR
 extern char *strerror(int);
@@ -79,4 +77,4 @@ int sigpipe_read();
 
 void sigpipe_close();
 
-#endif	/* !_PPTPD_COMPAT_H */
+#endif  /* !_PPTPD_COMPAT_H */

+ 0 - 2
config.embed.h

@@ -2,8 +2,6 @@
  * config.embed.h
  *
  * Dummy autoconf results for uClinux target.
- *
- * $Id: config.embed.h,v 1.4 2004/04/22 10:48:16 quozl Exp $
  */
 
 #define STDC_HEADERS 1

+ 0 - 2
config.h.in

@@ -3,8 +3,6 @@
  * acconfig.h
  *
  * Additional autoconf defines for this program.
- *
- * $Id: config.h.in,v 1.26 2011/05/19 00:02:50 quozl Exp $
  */
 
 /* Use BSD User land PPP? */

+ 99 - 101
configfile.c

@@ -3,8 +3,6 @@
  *
  * Methods for accessing the PPTPD config file and searching for
  * PPTPD keywords.
- *
- * $Id: configfile.c,v 1.3 2013/02/07 00:23:27 quozl Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -38,92 +36,92 @@ static void close_config_file(FILE * file);
  */
 int read_config_file(char *filename, char *keyword, char *value)
 {
-	FILE *in;
-	int len = 0, keyword_len = 0;
-	int foundit = 0;
-
-	char *buff_ptr;
-	char buffer[MAX_CONFIG_STRING_SIZE];
-
-	*value = '\0';
-	buff_ptr = buffer;
-	keyword_len = strlen(keyword);
-
-	in = open_config_file(filename);
-	if (in == NULL) {
-		/* Couldn't find config file, or permission denied */
-		return -1;
-	}
-	while ((fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in)) != NULL) {
-		/* ignore long lines */
-		if (buffer[(len = strlen(buffer)) - 1] != '\n') {
-			if (len >= MAX_CONFIG_STRING_SIZE - 2) {
-				syslog(LOG_ERR, "Long config file line ignored.");
-				char *p;
-				do
-					p = fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in);
-				while (p && buffer[strlen(buffer) - 1] != '\n');
-				continue;
-			}
-		} else {
-			len--;			/* For the NL at the end */
-		}
-
-		while (--len >= 0)
-			if (buffer[len] != ' ' && buffer[len] != '\t')
-				break;
-
-		len++;
-		buffer[len] = '\0';
-
-		buff_ptr = buffer;
-
-		/* Short-circuit blank lines and comments */
-		if (!len || *buff_ptr == '#')
-			continue;
-
-		/* Non-blank lines starting with a space are an error */
-
-		if (*buff_ptr == ' ' || *buff_ptr == '\t') {
-			syslog(LOG_ERR, "Config file line starts with a space: %s", buff_ptr);
-			continue;
-		}
-
-		/* At this point we have a line trimmed for trailing spaces. */
-		/* Now we need to check if the keyword matches, and if so */
-		/* then get the value (if any). */
-
-		/* Check if it's the right keyword */
-
-		do {
-			if (*buff_ptr == ' ' || *buff_ptr == '\t')
-				break;
-		} while (*++buff_ptr);
-
-		len = buff_ptr - buffer;
-		if (len == keyword_len && !strncmp(buffer, keyword, len)) {
-			foundit++;
-			break;
-		}
-	}
-
-	close_config_file(in);
-
-	if (foundit) {
-		/* Right keyword, now get the value (if any) */
-
-		do {
-			if (*buff_ptr != ' ' && *buff_ptr != '\t')
-				break;
-			
-		} while (*++buff_ptr);
-
-		strcpy(value, buff_ptr);
-		return 1;
-	} else {
-		/* didn't find it - better luck next time */
-		return 0;
-	}
+        FILE *in;
+        int len = 0, keyword_len = 0;
+        int foundit = 0;
+
+        char *buff_ptr;
+        char buffer[MAX_CONFIG_STRING_SIZE];
+
+        *value = '\0';
+        buff_ptr = buffer;
+        keyword_len = strlen(keyword);
+
+        in = open_config_file(filename);
+        if (in == NULL) {
+                /* Couldn't find config file, or permission denied */
+                return -1;
+        }
+        while ((fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in)) != NULL) {
+                /* ignore long lines */
+                if (buffer[(len = strlen(buffer)) - 1] != '\n') {
+                        if (len >= MAX_CONFIG_STRING_SIZE - 2) {
+                                syslog(LOG_ERR, "Long config file line ignored.");
+                                char *p;
+                                do
+                                        p = fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in);
+                                while (p && buffer[strlen(buffer) - 1] != '\n');
+                                continue;
+                        }
+                } else {
+                        len--;                  /* For the NL at the end */
+                }
+
+                while (--len >= 0)
+                        if (buffer[len] != ' ' && buffer[len] != '\t')
+                                break;
+
+                len++;
+                buffer[len] = '\0';
+
+                buff_ptr = buffer;
+
+                /* Short-circuit blank lines and comments */
+                if (!len || *buff_ptr == '#')
+                        continue;
+
+                /* Non-blank lines starting with a space are an error */
+
+                if (*buff_ptr == ' ' || *buff_ptr == '\t') {
+                        syslog(LOG_ERR, "Config file line starts with a space: %s", buff_ptr);
+                        continue;
+                }
+
+                /* At this point we have a line trimmed for trailing spaces. */
+                /* Now we need to check if the keyword matches, and if so */
+                /* then get the value (if any). */
+
+                /* Check if it's the right keyword */
+
+                do {
+                        if (*buff_ptr == ' ' || *buff_ptr == '\t')
+                                break;
+                } while (*++buff_ptr);
+
+                len = buff_ptr - buffer;
+                if (len == keyword_len && !strncmp(buffer, keyword, len)) {
+                        foundit++;
+                        break;
+                }
+        }
+
+        close_config_file(in);
+
+        if (foundit) {
+                /* Right keyword, now get the value (if any) */
+
+                do {
+                        if (*buff_ptr != ' ' && *buff_ptr != '\t')
+                                break;
+                        
+                } while (*++buff_ptr);
+
+                strcpy(value, buff_ptr);
+                return 1;
+        } else {
+                /* didn't find it - better luck next time */
+                return 0;
+        }
 }
 
 /*
@@ -138,18 +136,18 @@ int read_config_file(char *filename, char *keyword, char *value)
  */
 static FILE *open_config_file(char *filename)
 {
-	FILE *in;
-	static int first = 1;
-
-	if ((in = fopen(filename, "r")) == NULL) {
-		/* Couldn't open config file */
-		if (first) {
-			perror(filename);
-			first = 0;
-		}
-		return NULL;
-	}
-	return in;
+        FILE *in;
+        static int first = 1;
+
+        if ((in = fopen(filename, "r")) == NULL) {
+                /* Couldn't open config file */
+                if (first) {
+                        perror(filename);
+                        first = 0;
+                }
+                return NULL;
+        }
+        return in;
 }
 
 /*
@@ -160,5 +158,5 @@ static FILE *open_config_file(char *filename)
  */
 static void close_config_file(FILE * in)
 {
-	fclose(in);
+        fclose(in);
 }

+ 1 - 3
configfile.h

@@ -2,8 +2,6 @@
  * configfile.h
  *
  * Function to read pptpd config file.
- *
- * $Id: configfile.h,v 1.1 2002/06/21 08:51:55 fenix_nl Exp $
  */
 
 #ifndef _PPTPD_CONFIGFILE_H
@@ -11,4 +9,4 @@
 
 int read_config_file(char *filename, char *keyword, char *value);
 
-#endif	/* !_PPTPD_CONFIGFILE_H */
+#endif  /* !_PPTPD_CONFIGFILE_H */

File diff suppressed because it is too large
+ 561 - 424
configure


+ 1 - 1
configure.in

@@ -1,7 +1,7 @@
 AC_INIT(pptpmanager.c)
 
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(pptpd,1.3.4)
+AM_INIT_AUTOMAKE(pptpd,1.4.0)
 
 # check common command line options early
 

+ 412 - 417
ctrlpacket.c

@@ -2,8 +2,6 @@
  * ctrlpacket.c
  *
  * PPTP Control Message packet reading, formatting and writing.
- *
- * $Id: ctrlpacket.c,v 1.8 2008/11/13 23:49:22 quozl Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -37,11 +35,11 @@
 
 /* Local function prototypes */
 static ssize_t read_pptp_header(int clientFd, unsigned char *packet, int *ctrl_message_type);
-static void deal_start_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
-static void deal_stop_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
-static void deal_out_call(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
-static void deal_echo(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
-static void deal_call_clr(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
+static void deal_start_ctrl_conn(void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+static void deal_stop_ctrl_conn(void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+static void deal_out_call(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+static void deal_echo(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+static void deal_call_clr(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
 static void deal_set_link_info(unsigned char *packet);
 static u_int16_t getcall();
 static u_int16_t freecall();
@@ -66,58 +64,58 @@ static int make_out_call_rqst(unsigned char *rply_packet, ssize_t * rply_size);
  *              -1 on retryable error.
  *              0 on error to abort on.
  */
-int read_pptp_packet(int clientFd, unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
+int read_pptp_packet(int clientFd, void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
 
-	ssize_t bytes_read;
-	int pptp_ctrl_type = 0;	/* Control Message Type */
-
-	/* read a packet and parse header */
-	if ((bytes_read = read_pptp_header(clientFd, packet, &pptp_ctrl_type)) <= 0) {
-		/* error reading packet */
-		syslog(LOG_ERR, "CTRL: couldn't read packet header (%s)", bytes_read ? "retry" : "exit");
-		return bytes_read;
-	}
-
-	/* launch appropriate method to form suitable reply to the packet */
-	switch (pptp_ctrl_type) {
-	case START_CTRL_CONN_RQST:	/* Start Control Connection Request */
-		deal_start_ctrl_conn(packet, rply_packet, rply_size);
-		break;
-
-	case STOP_CTRL_CONN_RQST:
-		deal_stop_ctrl_conn(packet, rply_packet, rply_size);
-		break;
-
-	case OUT_CALL_RQST:		/* Outgoing Call Request */
-		deal_out_call(packet, rply_packet, rply_size);
-		break;
-
-	case ECHO_RQST:			/* Echo Request */
-		deal_echo(packet, rply_packet, rply_size);
-		break;
-
-	case CALL_CLR_RQST:		/* Call Clear Request (Disconnect Request) */
-		deal_call_clr(packet, rply_packet, rply_size);
-		break;
-
-	case SET_LINK_INFO:		/* Set Link Info */
-		/* no reply packet but process it */
-		deal_set_link_info(packet);
-		break;
-
-	case ECHO_RPLY:			/* Echo Reply */
-	case STOP_CTRL_CONN_RPLY:	/* Stop Control Connection Reply */
-	case CALL_DISCONN_NTFY:		/* Call Disconnect Notify */
-		/* no reply packet */
-		break;
-
-	default:
-		syslog(LOG_ERR, "CTRL: PPTP Control Message type %d not supported.", pptp_ctrl_type);
-		pptp_ctrl_type = -1;
-	}
-
-	return pptp_ctrl_type;
+        ssize_t bytes_read;
+        int pptp_ctrl_type = 0; /* Control Message Type */
+
+        /* read a packet and parse header */
+        if ((bytes_read = read_pptp_header(clientFd, packet, &pptp_ctrl_type)) <= 0) {
+                /* error reading packet */
+                syslog(LOG_ERR, "CTRL: couldn't read packet header (%s)", bytes_read ? "retry" : "exit");
+                return bytes_read;
+        }
+
+        /* launch appropriate method to form suitable reply to the packet */
+        switch (pptp_ctrl_type) {
+        case START_CTRL_CONN_RQST:      /* Start Control Connection Request */
+                deal_start_ctrl_conn(packet, rply_packet, rply_size);
+                break;
+
+        case STOP_CTRL_CONN_RQST:
+                deal_stop_ctrl_conn(packet, rply_packet, rply_size);
+                break;
+
+        case OUT_CALL_RQST:             /* Outgoing Call Request */
+                deal_out_call(packet, rply_packet, rply_size);
+                break;
+
+        case ECHO_RQST:                 /* Echo Request */
+                deal_echo(packet, rply_packet, rply_size);
+                break;
+
+        case CALL_CLR_RQST:             /* Call Clear Request (Disconnect Request) */
+                deal_call_clr(packet, rply_packet, rply_size);
+                break;
+
+        case SET_LINK_INFO:             /* Set Link Info */
+                /* no reply packet but process it */
+                deal_set_link_info(packet);
+                break;
+
+        case ECHO_RPLY:                 /* Echo Reply */
+        case STOP_CTRL_CONN_RPLY:       /* Stop Control Connection Reply */
+        case CALL_DISCONN_NTFY:         /* Call Disconnect Notify */
+                /* no reply packet */
+                break;
+
+        default:
+                syslog(LOG_ERR, "CTRL: PPTP Control Message type %d not supported.", pptp_ctrl_type);
+                pptp_ctrl_type = -1;
+        }
+
+        return pptp_ctrl_type;
 }
 
 
@@ -133,24 +131,24 @@ int read_pptp_packet(int clientFd, unsigned char *packet, unsigned char *rply_pa
  * retn:        Number of bytes written on success.
  *              -1 on write failure.
  */
-ssize_t send_pptp_packet(int clientFd, unsigned char *packet, size_t packet_size)
+ssize_t send_pptp_packet(int clientFd, void *packet, size_t packet_size)
 {
 
-	ssize_t bytes_written;
-
-	if ((bytes_written = write(clientFd, packet, packet_size)) == -1) {
-		/* write failed */
-		syslog(LOG_ERR, "CTRL: Couldn't write packet to client.");
-		return -1;
-
-	} else {
-		/* debugging */
-		if (pptpctrl_debug) {
-			syslog(LOG_DEBUG, "CTRL: I wrote %lu bytes to the client.", (unsigned long) packet_size);
-			syslog(LOG_DEBUG, "CTRL: Sent packet to client");
-		}
-		return bytes_written;
-	}
+        ssize_t bytes_written;
+
+        if ((bytes_written = write(clientFd, packet, packet_size)) == -1) {
+                /* write failed */
+                syslog(LOG_ERR, "CTRL: Couldn't write packet to client.");
+                return -1;
+
+        } else {
+                /* debugging */
+                if (pptpctrl_debug) {
+                        syslog(LOG_DEBUG, "CTRL: I wrote %lu bytes to the client.", (unsigned long) packet_size);
+                        syslog(LOG_DEBUG, "CTRL: Sent packet to client");
+                }
+                return bytes_written;
+        }
 }
 
 /*
@@ -167,21 +165,21 @@ ssize_t send_pptp_packet(int clientFd, unsigned char *packet, size_t packet_size
  *       0 if the error is important
  */
 static int ignoreErrno(int ierrno) {
-	switch (ierrno) {
-	case EAGAIN:		/* nothing to read */
-	case EINTR:		/* signal received */
+        switch (ierrno) {
+        case EAGAIN:            /* nothing to read */
+        case EINTR:             /* signal received */
 #ifdef ERESTART
 #if ERESTART != EINTR
-	case ERESTART:		/* signal received, should restart syscall */
+        case ERESTART:          /* signal received, should restart syscall */
 #endif
 #endif
 #if EWOULDBLOCK != EAGAIN
-	case EWOULDBLOCK:	/* shouldn't get this one but anyway, just in case */
+        case EWOULDBLOCK:       /* shouldn't get this one but anyway, just in case */
 #endif
-		return 1;
-	default:
-		return 0;
-	}
+                return 1;
+        default:
+                return 0;
+        }
 }
 
 /*
@@ -202,153 +200,153 @@ static int ignoreErrno(int ierrno) {
 ssize_t read_pptp_header(int clientFd, unsigned char *packet, int *pptp_ctrl_type)
 {
 
-	ssize_t bytes_ttl, bytes_this;	/* quantities read (total and this read) */
-	u_int16_t length;		/* length of this packet */
-	struct pptp_header *header;	/* the received header */
-
-	static char *buffer = NULL;	/* buffer between calls */
-	static int buffered = 0;	/* size of buffer */
-
-	*pptp_ctrl_type = 0;		/* initialise return arg	*/
-
-	/* read any previously buffered data */
-	if (buffered) {
-		memcpy(packet, buffer, buffered);
-		free(buffer);
-		buffer = NULL;
-		bytes_ttl = buffered;
-		buffered = 0;
-		if (pptpctrl_debug)
-			syslog(LOG_DEBUG, "CTRL: Read in previous incomplete ctrl packet");
-	} else
-		bytes_ttl = 0;
-
-	/* try and get the length in */
-	if (bytes_ttl < 2) {
-		bytes_this = read(clientFd, packet + bytes_ttl, 2 - bytes_ttl);
-		switch (bytes_this) {
-		case -1:
-			if (ignoreErrno(errno)) {
-				/* re-tryable error, re-buffer and return */
-				if (bytes_ttl) {
-					buffered = bytes_ttl;
-					buffer = malloc(bytes_ttl);
-					if (!buffer)
-						return(0);
-					memcpy(buffer, packet, bytes_ttl);
-				}
-				syslog(LOG_ERR, "CTRL: Error reading ctrl packet length (bytes_ttl=%lu): %s", (unsigned long) bytes_ttl, strerror(errno));
-				return -1;
-			}
-			/* FALLTHRU */
-		case 0:
-			syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet length.");
-			return 0;
-		default:
-			bytes_ttl += bytes_this;
-			/* Not enough data to proceed */
-			if (bytes_ttl == 1) {
-				buffered = bytes_ttl;
-				buffer = malloc(bytes_ttl);
-				if (!buffer)
-					return(0);
-				memcpy(buffer, packet, bytes_ttl);
-				if (pptpctrl_debug)
-					syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet length, retry later");
-				return -1;
-			}
-		}
-	}
-	/* OK, we have (at least) the first 2 bytes, and there is data waiting
-	 *
-	 * length includes the header,  so a length less than 2 is someone
-	 * trying to hack into us or a badly corrupted packet.
-	 * Why not require length to be at least 10? Since we later cast
-	 * packet to struct pptp_header and use at least the 10 first bytes..
-	 * Thanks to Timo Sirainen for mentioning this.
-	 */
-	length = htons(*(u_int16_t *) packet);
-	if (length <= 10 || length > PPTP_MAX_CTRL_PCKT_SIZE) {
-		syslog(LOG_ERR, "CTRL: 11 < Control packet (length=%d) < "
-				"PPTP_MAX_CTRL_PCKT_SIZE (%d)",
-				length, PPTP_MAX_CTRL_PCKT_SIZE);
-		/* we loose sync (unless we malloc something big, which isn't a good
-		 * idea - potential DoS) so we must close connection (draft states that
-		 * if you loose sync you must close the control connection immediately)
-		 */
-		return 0;
-	}
-	/* Now read the actual control packet */
-	bytes_this = read(clientFd, packet + bytes_ttl, length - bytes_ttl);
-	switch (bytes_this) {
-	case -1:
-		if(ignoreErrno(errno)) {
-			/* re-tryable error, re-buffer and return */
-			if (bytes_ttl) {
-				buffered = bytes_ttl;
-				buffer = malloc(bytes_ttl);
-				if (!buffer)
-					return(0);
-				memcpy(buffer, packet, bytes_ttl);
-			}
-			syslog(LOG_ERR, "CTRL: Error reading ctrl packet (bytes_ttl=%lu,length=%d): %s", (unsigned long) bytes_ttl, length, strerror(errno));
-			return -1;
-		}
-		/* FALLTHRU */
-	case 0:
-		syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet.");
-		return 0;
-	default:
-		bytes_ttl += bytes_this;
-		/* not enough data to proceed */
-		if (bytes_ttl != length) {
-			buffered = bytes_ttl;
-			buffer = malloc(bytes_ttl);
-			if (!buffer)
-				return(0);
-			memcpy(buffer, packet, bytes_ttl);
-			if (pptpctrl_debug)
-				syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet, retry later");
-			return -1;
-		}
-	}
-
-	/* We got one :-) */
-
-	/* Cast the packet into the PPTP Control Message format */
-	header = (struct pptp_header *) packet;
-
-	/* Packet sanity check on magic cookie */
-	if (ntohl(header->magic) != PPTP_MAGIC_COOKIE) {
-		/* Oops! Not a valid Control Message */
-		syslog(LOG_ERR, "CTRL: Bad magic cookie - lost syncronization, closing control connection.");
-		/* draft states loss of syncronization must result in
-		 * immediate closing of the control connection
-		 */
-		return 0;
-	}
-	/* Woohoo! Looks like we got a valid PPTP packet */
-	*pptp_ctrl_type = (int) (ntohs(header->ctrl_type));
-	if (pptpctrl_debug)
-		syslog(LOG_DEBUG, "CTRL: Received PPTP Control Message (type: %d)", *pptp_ctrl_type);
-	return bytes_ttl;
+        ssize_t bytes_ttl, bytes_this;  /* quantities read (total and this read) */
+        u_int16_t length;               /* length of this packet */
+        struct pptp_header *header;     /* the received header */
+
+        static char *buffer = NULL;     /* buffer between calls */
+        static int buffered = 0;        /* size of buffer */
+
+        *pptp_ctrl_type = 0;            /* initialise return arg        */
+
+        /* read any previously buffered data */
+        if (buffered) {
+                memcpy(packet, buffer, buffered);
+                free(buffer);
+                buffer = NULL;
+                bytes_ttl = buffered;
+                buffered = 0;
+                if (pptpctrl_debug)
+                        syslog(LOG_DEBUG, "CTRL: Read in previous incomplete ctrl packet");
+        } else
+                bytes_ttl = 0;
+
+        /* try and get the length in */
+        if (bytes_ttl < 2) {
+                bytes_this = read(clientFd, packet + bytes_ttl, 2 - bytes_ttl);
+                switch (bytes_this) {
+                case -1:
+                        if (ignoreErrno(errno)) {
+                                /* re-tryable error, re-buffer and return */
+                                if (bytes_ttl) {
+                                        buffered = bytes_ttl;
+                                        buffer = malloc(bytes_ttl);
+                                        if (!buffer)
+                                                return(0);
+                                        memcpy(buffer, packet, bytes_ttl);
+                                }
+                                syslog(LOG_ERR, "CTRL: Error reading ctrl packet length (bytes_ttl=%lu): %s", (unsigned long) bytes_ttl, strerror(errno));
+                                return -1;
+                        }
+                        /* FALLTHRU */
+                case 0:
+                        syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet length.");
+                        return 0;
+                default:
+                        bytes_ttl += bytes_this;
+                        /* Not enough data to proceed */
+                        if (bytes_ttl == 1) {
+                                buffered = bytes_ttl;
+                                buffer = malloc(bytes_ttl);
+                                if (!buffer)
+                                        return(0);
+                                memcpy(buffer, packet, bytes_ttl);
+                                if (pptpctrl_debug)
+                                        syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet length, retry later");
+                                return -1;
+                        }
+                }
+        }
+        /* OK, we have (at least) the first 2 bytes, and there is data waiting
+         *
+         * length includes the header,  so a length less than 2 is someone
+         * trying to hack into us or a badly corrupted packet.
+         * Why not require length to be at least 10? Since we later cast
+         * packet to struct pptp_header and use at least the 10 first bytes..
+         * Thanks to Timo Sirainen for mentioning this.
+         */
+        length = htons(*(u_int16_t *) packet);
+        if (length <= 10 || length > PPTP_MAX_CTRL_PCKT_SIZE) {
+                syslog(LOG_ERR, "CTRL: 11 < Control packet (length=%d) < "
+                                "PPTP_MAX_CTRL_PCKT_SIZE (%d)",
+                                length, PPTP_MAX_CTRL_PCKT_SIZE);
+                /* we loose sync (unless we malloc something big, which isn't a good
+                 * idea - potential DoS) so we must close connection (draft states that
+                 * if you loose sync you must close the control connection immediately)
+                 */
+                return 0;
+        }
+        /* Now read the actual control packet */
+        bytes_this = read(clientFd, packet + bytes_ttl, length - bytes_ttl);
+        switch (bytes_this) {
+        case -1:
+                if(ignoreErrno(errno)) {
+                        /* re-tryable error, re-buffer and return */
+                        if (bytes_ttl) {
+                                buffered = bytes_ttl;
+                                buffer = malloc(bytes_ttl);
+                                if (!buffer)
+                                        return(0);
+                                memcpy(buffer, packet, bytes_ttl);
+                        }
+                        syslog(LOG_ERR, "CTRL: Error reading ctrl packet (bytes_ttl=%lu,length=%d): %s", (unsigned long) bytes_ttl, length, strerror(errno));
+                        return -1;
+                }
+                /* FALLTHRU */
+        case 0:
+                syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet.");
+                return 0;
+        default:
+                bytes_ttl += bytes_this;
+                /* not enough data to proceed */
+                if (bytes_ttl != length) {
+                        buffered = bytes_ttl;
+                        buffer = malloc(bytes_ttl);
+                        if (!buffer)
+                                return(0);
+                        memcpy(buffer, packet, bytes_ttl);
+                        if (pptpctrl_debug)
+                                syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet, retry later");
+                        return -1;
+                }
+        }
+
+        /* We got one :-) */
+
+        /* Cast the packet into the PPTP Control Message format */
+        header = (struct pptp_header *) packet;
+
+        /* Packet sanity check on magic cookie */
+        if (ntohl(header->magic) != PPTP_MAGIC_COOKIE) {
+                /* Oops! Not a valid Control Message */
+                syslog(LOG_ERR, "CTRL: Bad magic cookie - lost syncronization, closing control connection.");
+                /* draft states loss of syncronization must result in
+                 * immediate closing of the control connection
+                 */
+                return 0;
+        }
+        /* Woohoo! Looks like we got a valid PPTP packet */
+        *pptp_ctrl_type = (int) (ntohs(header->ctrl_type));
+        if (pptpctrl_debug)
+                syslog(LOG_DEBUG, "CTRL: Received PPTP Control Message (type: %d)", *pptp_ctrl_type);
+        return bytes_ttl;
 }
 
 /* Macros to use in making response packets */
 
 #define MAKE_CTRL_HEADER(where, what) \
-	where.header.length = htons(sizeof(where)); \
-	where.header.pptp_type = htons(PPTP_CTRL_MESSAGE); \
-	where.header.magic = htonl(PPTP_MAGIC_COOKIE); \
-	where.header.ctrl_type = htons(what); \
-	where.header.reserved0 = htons(RESERVED)
+        where.header.length = htons(sizeof(where)); \
+        where.header.pptp_type = htons(PPTP_CTRL_MESSAGE); \
+        where.header.magic = htonl(PPTP_MAGIC_COOKIE); \
+        where.header.ctrl_type = htons(what); \
+        where.header.reserved0 = htons(RESERVED)
 
 #define COPY_CTRL_PACKET(from, to, size) \
-	memcpy(to, &from, ((*size) = sizeof(from)))
+        memcpy(to, &from, ((*size) = sizeof(from)))
 
 #define DEBUG_PACKET(what) \
-	if(pptpctrl_debug) \
-		syslog(LOG_DEBUG, "CTRL: Made a " what " packet")
+        if(pptpctrl_debug) \
+                syslog(LOG_DEBUG, "CTRL: Made a " what " packet")
 
 /*
  * deal_start_ctrl_conn
@@ -362,27 +360,24 @@ ssize_t read_pptp_header(int clientFd, unsigned char *packet, int *pptp_ctrl_typ
  *       rply_packet (OUT) - suitable reply to the 'packet' we got.
  *       rply_size (OUT) - size of the reply packet
  */
-void deal_start_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
+void deal_start_ctrl_conn(void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	struct pptp_start_ctrl_conn_rqst *start_ctrl_conn_rqst;
-	struct pptp_start_ctrl_conn_rply start_ctrl_conn_rply;
-
-	start_ctrl_conn_rqst = (struct pptp_start_ctrl_conn_rqst *) packet;
-
-	MAKE_CTRL_HEADER(start_ctrl_conn_rply, START_CTRL_CONN_RPLY);
-	start_ctrl_conn_rply.version = htons(PPTP_VERSION);
-	start_ctrl_conn_rply.result_code = CONNECTED;
-	start_ctrl_conn_rply.error_code = NO_ERROR;
-	start_ctrl_conn_rply.framing_cap = htons(OUR_FRAMING);
-	start_ctrl_conn_rply.bearer_cap = htons(OUR_BEARER);
-	start_ctrl_conn_rply.max_channels = htons(MAX_CHANNELS);
-	start_ctrl_conn_rply.firmware_rev = htons(PPTP_FIRMWARE_VERSION);
-	memset(start_ctrl_conn_rply.hostname, 0, MAX_HOSTNAME_SIZE);
-	strncpy((char *)start_ctrl_conn_rply.hostname, PPTP_HOSTNAME, MAX_HOSTNAME_SIZE);
-	memset(start_ctrl_conn_rply.vendor, 0, MAX_VENDOR_SIZE);
-	strncpy((char *)start_ctrl_conn_rply.vendor, PPTP_VENDOR, MAX_VENDOR_SIZE);
-	COPY_CTRL_PACKET(start_ctrl_conn_rply, rply_packet, rply_size);
-	DEBUG_PACKET("START CTRL CONN RPLY");
+        struct pptp_start_ctrl_conn_rply start_ctrl_conn_rply;
+
+        MAKE_CTRL_HEADER(start_ctrl_conn_rply, START_CTRL_CONN_RPLY);
+        start_ctrl_conn_rply.version = htons(PPTP_VERSION);
+        start_ctrl_conn_rply.result_code = CONNECTED;
+        start_ctrl_conn_rply.error_code = NO_ERROR;
+        start_ctrl_conn_rply.framing_cap = htons(OUR_FRAMING);
+        start_ctrl_conn_rply.bearer_cap = htons(OUR_BEARER);
+        start_ctrl_conn_rply.max_channels = htons(MAX_CHANNELS);
+        start_ctrl_conn_rply.firmware_rev = htons(PPTP_FIRMWARE_VERSION);
+        memset(start_ctrl_conn_rply.hostname, 0, MAX_HOSTNAME_SIZE);
+        strncpy((char *)start_ctrl_conn_rply.hostname, PPTP_HOSTNAME, MAX_HOSTNAME_SIZE);
+        memset(start_ctrl_conn_rply.vendor, 0, MAX_VENDOR_SIZE);
+        strncpy((char *)start_ctrl_conn_rply.vendor, PPTP_VENDOR, MAX_VENDOR_SIZE);
+        COPY_CTRL_PACKET(start_ctrl_conn_rply, rply_packet, rply_size);
+        DEBUG_PACKET("START CTRL CONN RPLY");
 }
 
 /*
@@ -391,16 +386,16 @@ void deal_start_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssi
  * This method response to a STOP-CONTROL-CONNECTION-REQUEST with a
  * STOP-CONTROL-CONNECTION-REPLY.
  */
-void deal_stop_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
+void deal_stop_ctrl_conn(void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	struct pptp_stop_ctrl_conn_rply stop_ctrl_conn_rply;
+        struct pptp_stop_ctrl_conn_rply stop_ctrl_conn_rply;
 
-	MAKE_CTRL_HEADER(stop_ctrl_conn_rply, STOP_CTRL_CONN_RPLY);
+        MAKE_CTRL_HEADER(stop_ctrl_conn_rply, STOP_CTRL_CONN_RPLY);
         stop_ctrl_conn_rply.result_code = DISCONNECTED;
         stop_ctrl_conn_rply.error_code = NO_ERROR;
         stop_ctrl_conn_rply.reserved1 = htons(RESERVED);
-	COPY_CTRL_PACKET(stop_ctrl_conn_rply, rply_packet, rply_size);
-	DEBUG_PACKET("STOP CTRL CONN RPLY");
+        COPY_CTRL_PACKET(stop_ctrl_conn_rply, rply_packet, rply_size);
+        DEBUG_PACKET("STOP CTRL CONN RPLY");
 }
 
 /*
@@ -416,42 +411,42 @@ void deal_stop_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssiz
  *       rply_size (OUT) - size of the reply packet
  *
  */
-void deal_out_call(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
+void deal_out_call(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	u_int16_t pac_call_id;
-	struct pptp_out_call_rqst *out_call_rqst;
-	struct pptp_out_call_rply out_call_rply;
-
-	out_call_rqst = (struct pptp_out_call_rqst *) packet;
-
-	if ((pac_call_id = getcall()) == htons(-1)) {
-		/* XXX should reject call */
-		syslog(LOG_ERR, "CTRL: No free Call IDs!");
-		pac_call_id = 0;
-	}
-	MAKE_CTRL_HEADER(out_call_rply, OUT_CALL_RPLY);
-	/* call_id is used for ctrl, call_id_peer is used for GRE
-	 * call_id_peer is what we were sent by the other end in ctrl initilization
-	 */
-	out_call_rply.call_id = pac_call_id;
-	out_call_rply.call_id_peer = out_call_rqst->call_id;
-	out_call_rply.result_code = CONNECTED;
-	out_call_rply.error_code = NO_ERROR;
-	out_call_rply.cause_code = NO_ERROR;
-	/* maybe limit to pppd speed? but pppd doesn't accept 10Mbps as a speed and yet
-	 * still performs at over 115200, eg, 60kbyte/sec and higher observed.
-	 */
-	out_call_rply.speed = out_call_rqst->max_bps;
-	/* lets match their window size for now... was htons(PCKT_RECV_WINDOW_SIZE)
-	 */
-	out_call_rply.pckt_recv_size = out_call_rqst->pckt_recv_size;
-	if(pptpctrl_debug)
-		syslog(LOG_DEBUG, "CTRL: Set parameters to %d maxbps, %d window size",
-			ntohl(out_call_rply.speed), ntohs(out_call_rply.pckt_recv_size));
-	out_call_rply.pckt_delay = htons(PCKT_PROCESS_DELAY);
-	out_call_rply.channel_id = htonl(CHANNEL_ID);
-	COPY_CTRL_PACKET(out_call_rply, rply_packet, rply_size);
-	DEBUG_PACKET("OUT CALL RPLY");
+        u_int16_t pac_call_id;
+        struct pptp_out_call_rqst *out_call_rqst;
+        struct pptp_out_call_rply out_call_rply;
+
+        out_call_rqst = (struct pptp_out_call_rqst *) packet;
+
+        if ((pac_call_id = getcall()) == htons(-1)) {
+                /* XXX should reject call */
+                syslog(LOG_ERR, "CTRL: No free Call IDs!");
+                pac_call_id = 0;
+        }
+        MAKE_CTRL_HEADER(out_call_rply, OUT_CALL_RPLY);
+        /* call_id is used for ctrl, call_id_peer is used for GRE
+         * call_id_peer is what we were sent by the other end in ctrl initilization
+         */
+        out_call_rply.call_id = pac_call_id;
+        out_call_rply.call_id_peer = out_call_rqst->call_id;
+        out_call_rply.result_code = CONNECTED;
+        out_call_rply.error_code = NO_ERROR;
+        out_call_rply.cause_code = NO_ERROR;
+        /* maybe limit to pppd speed? but pppd doesn't accept 10Mbps as a speed and yet
+         * still performs at over 115200, eg, 60kbyte/sec and higher observed.
+         */
+        out_call_rply.speed = out_call_rqst->max_bps;
+        /* lets match their window size for now... was htons(PCKT_RECV_WINDOW_SIZE)
+         */
+        out_call_rply.pckt_recv_size = out_call_rqst->pckt_recv_size;
+        if(pptpctrl_debug)
+                syslog(LOG_DEBUG, "CTRL: Set parameters to %d maxbps, %d window size",
+                        ntohl(out_call_rply.speed), ntohs(out_call_rply.pckt_recv_size));
+        out_call_rply.pckt_delay = htons(PCKT_PROCESS_DELAY);
+        out_call_rply.channel_id = htonl(CHANNEL_ID);
+        COPY_CTRL_PACKET(out_call_rply, rply_packet, rply_size);
+        DEBUG_PACKET("OUT CALL RPLY");
 }
 
 
@@ -468,20 +463,20 @@ void deal_out_call(unsigned char *packet, unsigned char *rply_packet, ssize_t *
  *       rply_size (OUT) - size of the reply packet
  *
  */
-void deal_echo(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
+void deal_echo(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	struct pptp_echo_rqst *echo_rqst;
-	struct pptp_echo_rply echo_rply;
-
-	echo_rqst = (struct pptp_echo_rqst *) packet;
-
-	MAKE_CTRL_HEADER(echo_rply, ECHO_RPLY);
-	echo_rply.identifier = echo_rqst->identifier;
-	echo_rply.result_code = CONNECTED;
-	echo_rply.error_code = NO_ERROR;
-	echo_rply.reserved1 = htons(RESERVED);
-	COPY_CTRL_PACKET(echo_rply, rply_packet, rply_size);
-	DEBUG_PACKET("ECHO RPLY");
+        struct pptp_echo_rqst *echo_rqst;
+        struct pptp_echo_rply echo_rply;
+
+        echo_rqst = (struct pptp_echo_rqst *) packet;
+
+        MAKE_CTRL_HEADER(echo_rply, ECHO_RPLY);
+        echo_rply.identifier = echo_rqst->identifier;
+        echo_rply.result_code = CONNECTED;
+        echo_rply.error_code = NO_ERROR;
+        echo_rply.reserved1 = htons(RESERVED);
+        COPY_CTRL_PACKET(echo_rply, rply_packet, rply_size);
+        DEBUG_PACKET("ECHO RPLY");
 }
 
 /*
@@ -497,28 +492,28 @@ void deal_echo(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply
  *       rply_size (OUT) - size of the reply packet
  *
  */
-void deal_call_clr(unsigned char *packet, unsigned char *rply_packet, ssize_t *rply_size)
+void deal_call_clr(unsigned char *packet, struct pptp_out_call_rply *rply_packet, ssize_t *rply_size)
 {
-	struct pptp_call_disconn_ntfy call_disconn_ntfy;
-	u_int16_t pac_call_id;
-
-	/* Form a reply
-	 * The reply packet is a CALL-DISCONECT-NOTIFY
-	 * In single call mode we don't care what peer's call ID is, so don't even bother looking
-	 */
-	if ((pac_call_id = freecall()) == htons(-1)) {
-		/* XXX should return an error */
-		syslog(LOG_ERR, "CTRL: Could not free Call ID [call clear]!");
-	}
-	MAKE_CTRL_HEADER(call_disconn_ntfy, CALL_DISCONN_NTFY);
-	call_disconn_ntfy.call_id = pac_call_id;
-	call_disconn_ntfy.result_code = CALL_CLEAR_REQUEST;	/* disconnected by call_clr_rqst */
-	call_disconn_ntfy.error_code = NO_ERROR;
-	call_disconn_ntfy.cause_code = htons(NO_ERROR);
-	call_disconn_ntfy.reserved1 = htons(RESERVED);
-	memset(call_disconn_ntfy.call_stats, 0, 128);
-	COPY_CTRL_PACKET(call_disconn_ntfy, rply_packet, rply_size);
-	DEBUG_PACKET("CALL DISCONNECT RPLY");
+        struct pptp_call_disconn_ntfy call_disconn_ntfy;
+        u_int16_t pac_call_id;
+
+        /* Form a reply
+         * The reply packet is a CALL-DISCONECT-NOTIFY
+         * In single call mode we don't care what peer's call ID is, so don't even bother looking
+         */
+        if ((pac_call_id = freecall()) == htons(-1)) {
+                /* XXX should return an error */
+                syslog(LOG_ERR, "CTRL: Could not free Call ID [call clear]!");
+        }
+        MAKE_CTRL_HEADER(call_disconn_ntfy, CALL_DISCONN_NTFY);
+        call_disconn_ntfy.call_id = pac_call_id;
+        call_disconn_ntfy.result_code = CALL_CLEAR_REQUEST;     /* disconnected by call_clr_rqst */
+        call_disconn_ntfy.error_code = NO_ERROR;
+        call_disconn_ntfy.cause_code = htons(NO_ERROR);
+        call_disconn_ntfy.reserved1 = htons(RESERVED);
+        memset(call_disconn_ntfy.call_stats, 0, 128);
+        COPY_CTRL_PACKET(call_disconn_ntfy, rply_packet, rply_size);
+        DEBUG_PACKET("CALL DISCONNECT RPLY");
 }
 
 /*
@@ -538,66 +533,66 @@ void deal_call_clr(unsigned char *packet, unsigned char *rply_packet, ssize_t *r
  */
 void deal_set_link_info(unsigned char *packet)
 {
-	struct pptp_set_link_info *set_link_info;
-
-	set_link_info = (struct pptp_set_link_info *) packet;
-	if (set_link_info->send_accm != 0xffffffff || set_link_info->recv_accm != 0xffffffff) {
-		/* Async-Control-Character-Map (ACCM) are bits that
-		   show which control characters should be escaped by the
-		   PPP implementation ... pptpd leaves pppd to negotiate
-		   that via LCP and does not process SET LINK INFO
-		   packets ... this is not complaint with the RFC but
-		   still works. */
-		if (pptpctrl_debug)
-			syslog(LOG_DEBUG, "CTRL: Ignored a SET LINK INFO packet with real ACCMs! (intentional non-compliance with section 2.15 of RFC 2637, ACCM is negotiated by PPP LCP asyncmap)");
-	} else if (pptpctrl_debug)
-		syslog(LOG_DEBUG, "CTRL: Got a SET LINK INFO packet with standard ACCMs");
+        struct pptp_set_link_info *set_link_info;
+
+        set_link_info = (struct pptp_set_link_info *) packet;
+        if (set_link_info->send_accm != 0xffffffff || set_link_info->recv_accm != 0xffffffff) {
+                /* Async-Control-Character-Map (ACCM) are bits that
+                   show which control characters should be escaped by the
+                   PPP implementation ... pptpd leaves pppd to negotiate
+                   that via LCP and does not process SET LINK INFO
+                   packets ... this is not complaint with the RFC but
+                   still works. */
+                if (pptpctrl_debug)
+                        syslog(LOG_DEBUG, "CTRL: Ignored a SET LINK INFO packet with real ACCMs! (intentional non-compliance with section 2.15 of RFC 2637, ACCM is negotiated by PPP LCP asyncmap)");
+        } else if (pptpctrl_debug)
+                syslog(LOG_DEBUG, "CTRL: Got a SET LINK INFO packet with standard ACCMs");
 }
 
-void make_echo_req_packet(unsigned char *rply_packet, ssize_t * rply_size, u_int32_t echo_id)
+void make_echo_req_packet(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size, u_int32_t echo_id)
 {
-	struct pptp_echo_rqst echo_packet;
+        struct pptp_echo_rqst echo_packet;
 
-	MAKE_CTRL_HEADER(echo_packet, ECHO_RQST);
-	echo_packet.identifier = echo_id;
-	COPY_CTRL_PACKET(echo_packet, rply_packet, rply_size);
-	DEBUG_PACKET("ECHO REQ");
+        MAKE_CTRL_HEADER(echo_packet, ECHO_RQST);
+        echo_packet.identifier = echo_id;
+        COPY_CTRL_PACKET(echo_packet, rply_packet, rply_size);
+        DEBUG_PACKET("ECHO REQ");
 }
 
-void make_stop_ctrl_req(unsigned char *rply_packet, ssize_t * rply_size)
+void make_stop_ctrl_req(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	struct pptp_stop_ctrl_conn_rqst stop_ctrl;
-
-	MAKE_CTRL_HEADER(stop_ctrl, STOP_CTRL_CONN_RQST);
-	stop_ctrl.reason = GENERAL_STOP_CTRL;
-	stop_ctrl.reserved1 = RESERVED;
-	stop_ctrl.reserved2 = htons(RESERVED);
-	COPY_CTRL_PACKET(stop_ctrl, rply_packet, rply_size);
-	DEBUG_PACKET("STOP CTRL REQ");
+        struct pptp_stop_ctrl_conn_rqst stop_ctrl;
+
+        MAKE_CTRL_HEADER(stop_ctrl, STOP_CTRL_CONN_RQST);
+        stop_ctrl.reason = GENERAL_STOP_CTRL;
+        stop_ctrl.reserved1 = RESERVED;
+        stop_ctrl.reserved2 = htons(RESERVED);
+        COPY_CTRL_PACKET(stop_ctrl, rply_packet, rply_size);
+        DEBUG_PACKET("STOP CTRL REQ");
 }
 
-void make_call_admin_shutdown(unsigned char *rply_packet, ssize_t * rply_size)
+void make_call_admin_shutdown(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size)
 {
-	struct pptp_call_disconn_ntfy call_disconn_ntfy;
-	u_int16_t pac_call_id;
-
-	/* Form a reply
-	 * The reply packet is a CALL-DISCONECT-NOTIFY
-	 * In single call mode we don't care what peer's call ID is, so don't even bother looking
-	 */
-	if ((pac_call_id = freecall()) == htons(-1)) {
-		/* XXX should return an error */
-		syslog(LOG_ERR, "CTRL: Could not free Call ID [admin shutdown]!");
-	}
-	MAKE_CTRL_HEADER(call_disconn_ntfy, CALL_DISCONN_NTFY);
-	call_disconn_ntfy.call_id = pac_call_id;
-	call_disconn_ntfy.result_code = ADMIN_SHUTDOWN;		/* disconnected by admin shutdown */
-	call_disconn_ntfy.error_code = NO_ERROR;
-	call_disconn_ntfy.cause_code = htons(NO_ERROR);
-	call_disconn_ntfy.reserved1 = htons(RESERVED);
-	memset(call_disconn_ntfy.call_stats, 0, 128);
-	COPY_CTRL_PACKET(call_disconn_ntfy, rply_packet, rply_size);
-	DEBUG_PACKET("CALL DISCONNECT RPLY");
+        struct pptp_call_disconn_ntfy call_disconn_ntfy;
+        u_int16_t pac_call_id;
+
+        /* Form a reply
+         * The reply packet is a CALL-DISCONECT-NOTIFY
+         * In single call mode we don't care what peer's call ID is, so don't even bother looking
+         */
+        if ((pac_call_id = freecall()) == htons(-1)) {
+                /* XXX should return an error */
+                syslog(LOG_ERR, "CTRL: Could not free Call ID [admin shutdown]!");
+        }
+        MAKE_CTRL_HEADER(call_disconn_ntfy, CALL_DISCONN_NTFY);
+        call_disconn_ntfy.call_id = pac_call_id;
+        call_disconn_ntfy.result_code = ADMIN_SHUTDOWN;         /* disconnected by admin shutdown */
+        call_disconn_ntfy.error_code = NO_ERROR;
+        call_disconn_ntfy.cause_code = htons(NO_ERROR);
+        call_disconn_ntfy.reserved1 = htons(RESERVED);
+        memset(call_disconn_ntfy.call_stats, 0, 128);
+        COPY_CTRL_PACKET(call_disconn_ntfy, rply_packet, rply_size);
+        DEBUG_PACKET("CALL DISCONNECT RPLY");
 }
 
 #if PNS_MODE
@@ -618,14 +613,14 @@ static unsigned int activeCalls[(MAX_CALLS / C_BITS) + 1];
  */
 int get_call_id(u_int16_t * loc)
 {
-	for (i = 0; i < MAX_CALLS; i++) {
-		if (!(activeCalls[C_SEG(i)] & C_BIT(i))) {
-			activeCalls[C_SEG(i)] |= C_BIT(i);
-			*loc = i;
-			return 0;
-		}
-	}
-	return -1;
+        for (i = 0; i < MAX_CALLS; i++) {
+                if (!(activeCalls[C_SEG(i)] & C_BIT(i))) {
+                        activeCalls[C_SEG(i)] |= C_BIT(i);
+                        *loc = i;
+                        return 0;
+                }
+        }
+        return -1;
 }
 
 /*
@@ -636,10 +631,10 @@ int get_call_id(u_int16_t * loc)
  */
 int free_call_id(u_int16_t call_id)
 {
-	if (!(activeCalls[C_SEG(i)] & C_BIT(i)))
-		return -1;
-	activeCalls[C_SEG(i)] &= ~C_BIT(i);
-	return 0;
+        if (!(activeCalls[C_SEG(i)] & C_BIT(i)))
+                return -1;
+        activeCalls[C_SEG(i)] &= ~C_BIT(i);
+        return 0;
 }
 #else
 static int _pac_call_id;
@@ -655,36 +650,36 @@ static u_int16_t _pac_init = 0;
  */
 u_int16_t getcall()
 {
-	static u_int16_t i = 0;
-	extern u_int16_t unique_call_id;
-
-	/* Start with a random Call ID.  This is to allocate unique
-	 * Call ID's across multiple TCP PPTP connections.  In this
-	 * way remote clients masqueraded by a firewall will put
-	 * unique peer call ID's into GRE packets that will have the
-	 * same source IP address of the firewall. */
-
-	if (!i) {
-		if (unique_call_id == 0xFFFF) {
-			struct timeval tv;
-			if (gettimeofday(&tv, NULL) == 0) {
-				i = ((tv.tv_sec & 0x0FFF) << 4) + 
-				    (tv.tv_usec >> 16);
-			}
-		} else {
-			i = unique_call_id;
-		}
-	}
-
-	if(!_pac_init) {
-		_pac_call_id = htons(-1);
-		_pac_init = 1;
-	}
-	if(_pac_call_id != htons(-1))
-		syslog(LOG_ERR, "CTRL: Asked to allocate call id when call open, not handled well");
-	_pac_call_id = htons(i);
-	i++;
-	return _pac_call_id;
+        static u_int16_t i = 0;
+        extern u_int16_t unique_call_id;
+
+        /* Start with a random Call ID.  This is to allocate unique
+         * Call ID's across multiple TCP PPTP connections.  In this
+         * way remote clients masqueraded by a firewall will put
+         * unique peer call ID's into GRE packets that will have the
+         * same source IP address of the firewall. */
+
+        if (!i) {
+                if (unique_call_id == 0xFFFF) {
+                        struct timeval tv;
+                        if (gettimeofday(&tv, NULL) == 0) {
+                                i = ((tv.tv_sec & 0x0FFF) << 4) + 
+                                    (tv.tv_usec >> 16);
+                        }
+                } else {
+                        i = unique_call_id;
+                }
+        }
+
+        if(!_pac_init) {
+                _pac_call_id = htons(-1);
+                _pac_init = 1;
+        }
+        if(_pac_call_id != htons(-1))
+                syslog(LOG_ERR, "CTRL: Asked to allocate call id when call open, not handled well");
+        _pac_call_id = htons(i);
+        i++;
+        return _pac_call_id;
 }
 
 /*
@@ -696,16 +691,16 @@ u_int16_t getcall()
  */
 u_int16_t freecall()
 {
-	u_int16_t ret;
-
-	if(!_pac_init) {
-		_pac_call_id = htons(-1);
-		_pac_init = 1;
-	}
-	ret = _pac_call_id;
-	if(_pac_call_id == htons(-1))
-		syslog(LOG_ERR, "CTRL: Asked to free call when no call open, not handled well");
-	_pac_call_id = htons(-1);
-	return ret;
+        u_int16_t ret;
+
+        if(!_pac_init) {
+                _pac_call_id = htons(-1);
+                _pac_init = 1;
+        }
+        ret = _pac_call_id;
+        if(_pac_call_id == htons(-1))
+                syslog(LOG_ERR, "CTRL: Asked to free call when no call open, not handled well");
+        _pac_call_id = htons(-1);
+        return ret;
 }
 #endif

+ 6 - 8
ctrlpacket.h

@@ -2,17 +2,15 @@
  * ctrlpacket.h
  *
  * Functions to parse and send pptp control packets.
- *
- * $Id: ctrlpacket.h,v 1.1 2002/06/21 08:51:58 fenix_nl Exp $
  */
 
 #ifndef _PPTPD_CTRLPACKET_H
 #define _PPTPD_CTRLPACKET_H
 
-int read_pptp_packet(int clientFd, unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
-ssize_t send_pptp_packet(int clientFd, unsigned char *packet, size_t packet_size);
-void make_echo_req_packet(unsigned char *rply_packet, ssize_t * rply_size, u_int32_t echo_id);
-void make_call_admin_shutdown(unsigned char *rply_packet, ssize_t * rply_size);
-void make_stop_ctrl_req(unsigned char *rply_packet, ssize_t * rply_size);
+int read_pptp_packet(int clientFd, void *packet, struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+ssize_t send_pptp_packet(int clientFd, void *packet, size_t packet_size);
+void make_echo_req_packet(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size, u_int32_t echo_id);
+void make_call_admin_shutdown(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
+void make_stop_ctrl_req(struct pptp_out_call_rply *rply_packet, ssize_t * rply_size);
 
-#endif	/* !_PPTPD_CTRLPACKET_H */
+#endif  /* !_PPTPD_CTRLPACKET_H */

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+pptpd (1.4.0-0) unstable; urgency=low
+
+  * Package built from upstream sources, not a Debian project package
+    (Debian Developer expected to adjust this entry)
+
+ -- James Cameron <quozl@laptop.org>  Wed, 23 Oct 2013 16:16:54 +1000
+
 pptpd (1.3.4-0) unstable; urgency=low
 
   * Package built from upstream sources, not a Debian project package

+ 0 - 1
debian/crontab.ex

@@ -1 +0,0 @@
-0 4	* * *	root	pptpd_maintenance

+ 0 - 1
debian/diversions.ex

@@ -1 +0,0 @@
-<FILE> <Diverted to> <Packagename>

+ 0 - 2
debian/inetd.conf.ex

@@ -1,2 +0,0 @@
-#:OTHER:
-pptpd	stream	tcp	nowait	root	/usr/sbin/tcpd /usr/sbin/pptpd

+ 0 - 15
debian/info.ex

@@ -1,15 +0,0 @@
-# This is a configuration files for installing a .info menu
-# The Description to be placed into the directory
-DESCR="Description"
-
-# The section this info file should be placed in (Regexp) followed by
-# the new section name to be created if the Regexp does not match
-# (Optional. If not given the .info will be appended to the directory)
-#SECTION_MATCH="Regexp"
-#SECTION_NAME="New Section Name"
-
-# The file referred to from the Info directory
-FILE=pptpd.info
-
-# Optional. The files to be copied to /usr/info
-#FILES=*.info

+ 0 - 5
debian/watch.ex

@@ -1,5 +0,0 @@
-# Example watch control file for uscan
-# Rename this file to "watch" and then you can run the "uscan" command
-# to check for upstream updates and more.
-# Site		Directory		Pattern			Version	Script
-sunsite.unc.edu	/pub/Linux/Incomingu	pptpd-*.tar.gz	debian	uupdate

+ 32 - 34
defaults.h

@@ -3,8 +3,6 @@
  *
  * This file contains some tuneable parameters, most of which can be overriden
  * at run-time.
- *
- * $Id: defaults.h,v 1.10 2011/05/19 00:02:50 quozl Exp $
  */
 
 #ifndef _PPTPD_DEFAULTS_H
@@ -19,8 +17,8 @@
 
 /* String sizes for the config file */
 
-#define MAX_CONFIG_FILENAME_SIZE	256
-#define MAX_CONFIG_STRING_SIZE		512
+#define MAX_CONFIG_FILENAME_SIZE        256
+#define MAX_CONFIG_STRING_SIZE          512
 
 /* For IP parser */
 
@@ -29,50 +27,50 @@
 
 /* Default configuration values, mostly configurable */
 
-#define CONNECTIONS_DEFAULT		100
-#define DEFAULT_LOCAL_IP_LIST		"192.168.0.1-100"
-#define DEFAULT_REMOTE_IP_LIST		"192.168.1.1-100"
+#define CONNECTIONS_DEFAULT             100
+#define DEFAULT_LOCAL_IP_LIST           "192.168.0.1-100"
+#define DEFAULT_REMOTE_IP_LIST          "192.168.1.1-100"
 
-#define MAX_CALLS_PER_TCP_LINK		128
+#define MAX_CALLS_PER_TCP_LINK          128
 
 #ifdef PNS_MODE
-#define MAX_CALLS			60
+#define MAX_CALLS                       60
 #endif
 
-#define PPP_SPEED_DEFAULT		"115200"
+#define PPP_SPEED_DEFAULT               "115200"
 #if EMBED
-#define PPTPD_CONFIG_FILE_DEFAULT	"/etc/config/pptpd.conf"
+#define PPTPD_CONFIG_FILE_DEFAULT       "/etc/config/pptpd.conf"
 #else
-#define PPTPD_CONFIG_FILE_DEFAULT	"/etc/pptpd.conf"
+#define PPTPD_CONFIG_FILE_DEFAULT       "/etc/pptpd.conf"
 #endif
-#define PIDFILE_DEFAULT			"/var/run/pptpd.pid"
+#define PIDFILE_DEFAULT                 "/var/run/pptpd.pid"
 
-#define STIMEOUT_DEFAULT		10 /* seconds */
+#define STIMEOUT_DEFAULT                10 /* seconds */
 
 /* Location of binaries */
 
-#define PPTP_CTRL_BIN			SBINDIR "/pptpctrl"
-#define PPTPD_BIN			SBINDIR "/pptpd"
-#define BCRELAY_BIN			SBINDIR "/bcrelay"
+#define PPTP_CTRL_BIN                   SBINDIR "/pptpctrl"
+#define PPTPD_BIN                       SBINDIR "/pptpd"
+#define BCRELAY_BIN                     SBINDIR "/bcrelay"
 
 /* Parameters permitted in the config file */
 
-#define CONNECTIONS_KEYWORD		"connections"
-#define SPEED_KEYWORD			"speed"
-#define PPPD_OPTION_KEYWORD		"option"
-#define DEBUG_KEYWORD			"debug"
+#define CONNECTIONS_KEYWORD             "connections"
+#define SPEED_KEYWORD                   "speed"
+#define PPPD_OPTION_KEYWORD             "option"
+#define DEBUG_KEYWORD                   "debug"
 #ifdef BCRELAY
-#define BCRELAY_KEYWORD			"bcrelay"
+#define BCRELAY_KEYWORD                 "bcrelay"
 #endif
-#define LOCALIP_KEYWORD			"localip"
-#define REMOTEIP_KEYWORD		"remoteip"
-#define LISTEN_KEYWORD			"listen"
-#define VRF_KEYWORD			"vrf"
-#define PIDFILE_KEYWORD			"pidfile"
-#define STIMEOUT_KEYWORD		"stimeout"
-#define NOIPPARAM_KEYWORD		"noipparam"
-#define PPP_BINARY_KEYWORD		"ppp"
-#define LOGWTMP_KEYWORD			"logwtmp"
-#define DELEGATE_KEYWORD		"delegate"
-
-#endif	/* !_PPTPD_DEFAULTS_H */
+#define LOCALIP_KEYWORD                 "localip"
+#define REMOTEIP_KEYWORD                "remoteip"
+#define LISTEN_KEYWORD                  "listen"
+#define VRF_KEYWORD                     "vrf"
+#define PIDFILE_KEYWORD                 "pidfile"
+#define STIMEOUT_KEYWORD                "stimeout"
+#define NOIPPARAM_KEYWORD               "noipparam"
+#define PPP_BINARY_KEYWORD              "ppp"
+#define LOGWTMP_KEYWORD                 "logwtmp"
+#define DELEGATE_KEYWORD                "delegate"
+
+#endif  /* !_PPTPD_DEFAULTS_H */

File diff suppressed because it is too large
+ 449 - 451
getopt.c


+ 58 - 60
getopt1.c

@@ -5,8 +5,6 @@
  *
  * NOTE: Changed to make dependencies work better:
  *        * <config.h> changed to "config.h"
- *
- * $Id: getopt1.c,v 1.1 2002/06/21 08:51:58 fenix_nl Exp $
  */
 
 /* getopt_long and getopt_long_only entry points for GNU getopt.
@@ -70,7 +68,7 @@
 #include <stdlib.h>
 #endif
 
-#ifndef	NULL
+#ifndef NULL
 #define NULL 0
 #endif
 
@@ -102,7 +100,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
 }
 
 
-#endif	/* Not ELIDE_CODE.  */
+#endif  /* Not ELIDE_CODE.  */
 
 #ifdef TEST
 
@@ -122,74 +120,74 @@ main (argc, argv)
       int option_index = 0;
       static struct option long_options[] =
       {
-	{"add", 1, 0, 0},
-	{"append", 0, 0, 0},
-	{"delete", 1, 0, 0},
-	{"verbose", 0, 0, 0},
-	{"create", 0, 0, 0},
-	{"file", 1, 0, 0},
-	{0, 0, 0, 0}
+        {"add", 1, 0, 0},
+        {"append", 0, 0, 0},
+        {"delete", 1, 0, 0},
+        {"verbose", 0, 0, 0},
+        {"create", 0, 0, 0},
+        {"file", 1, 0, 0},
+        {0, 0, 0, 0}
       };
 
       c = getopt_long (argc, argv, "abc:d:0123456789",
-		       long_options, &option_index);
+                       long_options, &option_index);
       if (c == -1)
-	break;
+        break;
 
       switch (c)
-	{
-	case 0:
-	  printf ("option %s", long_options[option_index].name);
-	  if (optarg)
-	    printf (" with arg %s", optarg);
-	  printf ("\n");
-	  break;
-
-	case '0':
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-	case '5':
-	case '6':
-	case '7':
-	case '8':
-	case '9':
-	  if (digit_optind != 0 && digit_optind != this_option_optind)
-	    printf ("digits occur in two different argv-elements.\n");
-	  digit_optind = this_option_optind;
-	  printf ("option %c\n", c);
-	  break;
-
-	case 'a':
-	  printf ("option a\n");
-	  break;
-
-	case 'b':
-	  printf ("option b\n");
-	  break;
-
-	case 'c':
-	  printf ("option c with value `%s'\n", optarg);
-	  break;
-
-	case 'd':
-	  printf ("option d with value `%s'\n", optarg);
-	  break;
-
-	case '?':
-	  break;
-
-	default:
-	  printf ("?? getopt returned character code 0%o ??\n", c);
-	}
+        {
+        case 0:
+          printf ("option %s", long_options[option_index].name);
+          if (optarg)
+            printf (" with arg %s", optarg);
+          printf ("\n");
+          break;
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+          if (digit_optind != 0 && digit_optind != this_option_optind)
+            printf ("digits occur in two different argv-elements.\n");
+          digit_optind = this_option_optind;
+          printf ("option %c\n", c);
+          break;
+
+        case 'a':
+          printf ("option a\n");
+          break;
+
+        case 'b':
+          printf ("option b\n");
+          break;
+
+        case 'c':
+          printf ("option c with value `%s'\n", optarg);
+          break;
+
+        case 'd':
+          printf ("option d with value `%s'\n", optarg);
+          break;
+
+        case '?':
+          break;
+
+        default:
+          printf ("?? getopt returned character code 0%o ??\n", c);
+        }
     }
 
   if (optind < argc)
     {
       printf ("non-option ARGV-elements: ");
       while (optind < argc)
-	printf ("%s ", argv[optind++]);
+        printf ("%s ", argv[optind++]);
       printf ("\n");
     }
 

+ 27 - 29
inststr.c

@@ -4,8 +4,6 @@
  * Little function to change the name of a process
  *
  * Originally from C. S. Ananian's pptpclient
- *
- * $Id: inststr.c,v 1.2 2004/04/22 10:48:16 quozl Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -19,33 +17,33 @@
 
 void inststr(int argc, char **argv, char *src)
 {
-	if (strlen(src) <= strlen(argv[0])) {
-		char *ptr, **pptr;
+        if (strlen(src) <= strlen(argv[0])) {
+                char *ptr, **pptr;
 
-		for (ptr = argv[0]; *ptr; *(ptr++) = '\0')
-			;
-		strcpy(argv[0], src);
-		for (pptr = argv + 1; *pptr; pptr++)
-			for (ptr = *pptr; *ptr; *(ptr++) = '\0')
-				;
-	} else {
-		/* Originally from the source to perl 4.036 (assigning to $0) */
-		char *ptr, *ptr2;
-		int count;
+                for (ptr = argv[0]; *ptr; *(ptr++) = '\0')
+                        ;
+                strcpy(argv[0], src);
+                for (pptr = argv + 1; *pptr; pptr++)
+                        for (ptr = *pptr; *ptr; *(ptr++) = '\0')
+                                ;
+        } else {
+                /* Originally from the source to perl 4.036 (assigning to $0) */
+                char *ptr, *ptr2;
+                int count;
 
-		ptr = argv[0] + strlen(argv[0]);
-		for (count = 1; count < argc; count++) {
-			if (argv[count] == ptr + 1) {
-				ptr++;
-				ptr += strlen(ptr);
-			}
-		}
-		count = 0;
-		for (ptr2 = argv[0]; ptr2 <= ptr; ptr2++) {
-			*ptr2 = '\0';
-			count++;
-		}
-		strlcpy(argv[0], src, count);
-	}
+                ptr = argv[0] + strlen(argv[0]);
+                for (count = 1; count < argc; count++) {
+                        if (argv[count] == ptr + 1) {
+                                ptr++;
+                                ptr += strlen(ptr);
+                        }
+                }
+                count = 0;
+                for (ptr2 = argv[0]; ptr2 <= ptr; ptr2++) {
+                        *ptr2 = '\0';
+                        count++;
+                }
+                strlcpy(argv[0], src, count);
+        }
 }
-#endif	/* !HAVE_SETPROCTITLE */
+#endif  /* !HAVE_SETPROCTITLE */

+ 1 - 3
inststr.h

@@ -3,8 +3,6 @@
  *
  * Change process title
  * From code by C. S. Ananian
- *
- * $Id: inststr.h,v 1.1 2002/06/21 08:52:00 fenix_nl Exp $
  */
 
 #ifndef _PPTPD_INSTSTR_H
@@ -14,4 +12,4 @@
 void inststr(int argc, char **argv, char *src);
 #endif
 
-#endif	/* !_PPTPD_INSTSTR_H */
+#endif  /* !_PPTPD_INSTSTR_H */

+ 15 - 17
our_getopt.h

@@ -2,8 +2,6 @@
  * our_getopt.h
  *
  * Header file for the getopt_long deprived.
- *
- * $Id: our_getopt.h,v 1.1 2002/06/21 08:52:00 fenix_nl Exp $
  */
 
 /* Declarations for getopt.
@@ -31,7 +29,7 @@
 # define _GETOPT_H 1
 #endif
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 extern "C" {
 #endif
 
@@ -73,9 +71,9 @@ extern int optopt;
    zero.
 
    The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
+   no_argument          (or 0) if the option does not take an argument,
+   required_argument    (or 1) if the option requires an argument,
+   optional_argument    (or 2) if the option takes an optional argument.
 
    If the field `flag' is not NULL, it points to a variable that is set
    to the value given in the field `val' when the option is found, but
@@ -104,10 +102,10 @@ struct option
 
 /* Names for the values of the `has_arg' field of `struct option'.  */
 
-# define no_argument		0
-# define required_argument	1
-# define optional_argument	2
-#endif	/* need getopt */
+# define no_argument            0
+# define required_argument      1
+# define optional_argument      2
+#endif  /* need getopt */
 
 
 /* Get definitions and prototypes for functions to process the
@@ -146,16 +144,16 @@ extern int getopt ();
 
 # ifndef __need_getopt
 extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
-		        const struct option *__longopts, int *__longind);
+                        const struct option *__longopts, int *__longind);
 extern int getopt_long_only (int __argc, char *const *__argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind);
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind);
 
 /* Internal only.  Users should not call this directly.  */
 extern int _getopt_internal (int __argc, char *const *__argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind,
-			     int __long_only);
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind,
+                             int __long_only);
 # endif
 #else /* not __STDC__ */
 extern int getopt ();
@@ -167,7 +165,7 @@ extern int _getopt_internal ();
 # endif
 #endif /* __STDC__ */
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 }
 #endif
 

+ 7 - 9
our_syslog.h

@@ -2,31 +2,29 @@
  * our_syslog.h
  *
  * Syslog replacement functions
- *
- * $Id: our_syslog.h,v 1.1 2002/06/21 08:52:00 fenix_nl Exp $
  */
 
 #ifndef _PPTPD_SYSLOG_H
 #define _PPTPD_SYSLOG_H
 
 /*
- *	only enable this if you are debugging and running by hand
- *	If init runs us you may not have an fd-2,  and thus your write all over
- *	someones FD and the die :-(
+ *      only enable this if you are debugging and running by hand
+ *      If init runs us you may not have an fd-2,  and thus your write all over
+ *      someones FD and the die :-(
  */
 #undef USE_STDERR
 
 #ifdef USE_STDERR
 
 /*
- *	Send all errors to stderr
+ *      Send all errors to stderr
  */
 
 #define openlog(a,b,c) ({})
 #define syslog(a,b,c...) ({fprintf(stderr, "pptpd syslog: " b "\n" , ## c);})
 #define closelog() ({})
 
-#define syslog_perror	perror
+#define syslog_perror   perror
 
 #else
 
@@ -37,8 +35,8 @@
 #include <errno.h>
 #include <syslog.h>
 
-#define syslog_perror(s)	syslog(LOG_ERR, "%s: %s", s, strerror(errno))
+#define syslog_perror(s)        syslog(LOG_ERR, "%s: %s", s, strerror(errno))
 
 #endif
 
-#endif	/* !_PPTPD_SYSLOG_H */
+#endif  /* !_PPTPD_SYSLOG_H */

+ 38 - 40
ppphdlc.c

@@ -3,8 +3,6 @@
  *
  * Copied from C. S. Ananian's linux client ppp_fcs.c
  * This code can also be found in RFC1662
- *
- * $Id: ppphdlc.c,v 1.1 2002/06/21 08:52:00 fenix_nl Exp $
  */
 
 /* Fast Frame Check Sequence (FCS) Implementation, for HDLC-like framing of
@@ -37,45 +35,45 @@
  */
 u_int16_t fcstab[256] =
 {
-	0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
-	0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
-	0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
-	0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
-	0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
-	0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
-	0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
-	0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
-	0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
-	0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
-	0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
-	0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
-	0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
-	0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
-	0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
-	0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
-	0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
-	0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
-	0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
-	0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
-	0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
-	0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
-	0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
-	0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
-	0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
-	0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
-	0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
-	0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
-	0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
-	0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
-	0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
-	0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+        0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+        0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+        0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+        0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+        0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+        0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+        0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+        0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+        0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+        0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+        0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+        0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+        0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+        0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+        0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+        0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+        0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+        0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+        0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+        0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+        0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+        0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+        0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+        0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+        0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+        0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+        0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+        0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+        0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+        0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+        0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+        0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
 };
 
 #ifndef PPPINITFCS16
-#define PPPINITFCS16    0xffff	/* Initial FCS value */
+#define PPPINITFCS16    0xffff  /* Initial FCS value */
 #endif
 #ifndef PPPGOODFCS16
-#define PPPGOODFCS16    0xf0b8	/* Good final FCS value */
+#define PPPGOODFCS16    0xf0b8  /* Good final FCS value */
 #endif
 
 #if 0
@@ -86,11 +84,11 @@ u_int16_t fcstab[256] =
  */
 u_int16_t pppfcs16(u_int16_t fcs, void *_cp, int len)
 {
-	register unsigned char *cp = (unsigned char *) _cp;
+        register unsigned char *cp = (unsigned char *) _cp;
 
-	while (len--)
-		fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
+        while (len--)
+                fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
 
-	return (fcs);
+        return (fcs);
 }
 #endif

+ 3 - 5
ppphdlc.h

@@ -2,16 +2,14 @@
  * ppphdlc.h
  *
  * Copied from C. S. Ananians ppp_fcs.h
- *
- * $Id: ppphdlc.h,v 1.1 2002/06/21 08:52:00 fenix_nl Exp $
  */
 
 #ifndef _PPTPD_PPPHDLC_H
 #define _PPTPD_PPPHDLC_H
 
-#define PPPINITFCS16    0xffff	/* Initial FCS value */
-#define PPPGOODFCS16    0xf0b8	/* Good final FCS value */
+#define PPPINITFCS16    0xffff  /* Initial FCS value */
+#define PPPGOODFCS16    0xf0b8  /* Good final FCS value */
 
 extern u_int16_t fcstab[256];
 
-#endif	/* !_PPTPD_PPPHDLC_H */
+#endif  /* !_PPTPD_PPPHDLC_H */

File diff suppressed because it is too large
+ 559 - 561
pptpctrl.c


+ 1 - 3
pptpctrl.h

@@ -2,8 +2,6 @@
  * pptpctrl.h
  *
  * PPTP control function prototypes.
- *
- * $Id: pptpctrl.h,v 1.2 2011/05/19 00:02:50 quozl Exp $
  */
 
 #ifndef _PPTPD_PPTPCTRL_H
@@ -17,4 +15,4 @@ extern char *vrf;
 #define vrf_socket(vrf, dom, typ, prot) socket(dom, typ, prot)
 #endif
 
-#endif	/* !_PPTPD_PPTPCTRL_H */
+#endif  /* !_PPTPD_PPTPCTRL_H */

File diff suppressed because it is too large
+ 562 - 558
pptpd.c


+ 1 - 1
pptpd.spec

@@ -12,7 +12,7 @@
 
 Summary:        PoPToP Point to Point Tunneling Server
 Name:           pptpd
-Version:        1.3.4
+Version:        1.4.0
 Release:        1%{?dist}
 License:        GPL
 Group:          Applications/Internet

+ 190 - 192
pptpdefs.h

@@ -2,8 +2,6 @@
  * pptpdefs.h
  *
  * PPTP structs and defines
- *
- * $Id: pptpdefs.h,v 1.5 2007/07/20 00:34:09 quozl Exp $
  */
 
 #ifndef _PPTPD_PPTPDEFS_H
@@ -20,295 +18,295 @@
 #include <sys/types.h>
 
 /* PPTP ctrl message port */
-#define PPTP_PORT			1723
+#define PPTP_PORT                       1723
 
 /* PPTP gre prototype */
-#define PPTP_PROTO			47
+#define PPTP_PROTO                      47
 
 /* PPTP version */
-#define PPTP_VERSION			0x0100
-#define	PPTP_FIRMWARE_VERSION		0x0001
+#define PPTP_VERSION                    0x0100
+#define PPTP_FIRMWARE_VERSION           0x0001
 
 /* Hostname and Vendor */
-#define PPTP_HOSTNAME			"local"
-#define PPTP_VENDOR			"linux"
+#define PPTP_HOSTNAME                   "local"
+#define PPTP_VENDOR                     "linux"
 
-#define MAX_HOSTNAME_SIZE		64
-#define MAX_VENDOR_SIZE			64
+#define MAX_HOSTNAME_SIZE               64
+#define MAX_VENDOR_SIZE                 64
 
 /* Magic Cookie */
-#define PPTP_MAGIC_COOKIE		0x1a2b3c4d
+#define PPTP_MAGIC_COOKIE               0x1a2b3c4d
 
 /* Message types */
-#define PPTP_CTRL_MESSAGE		1
+#define PPTP_CTRL_MESSAGE               1
 
 /* Maximum size of any PPTP control packet we will get */
-#define PPTP_MAX_CTRL_PCKT_SIZE		220
+#define PPTP_MAX_CTRL_PCKT_SIZE         220
 
 /* Control Connection Management */
-#define START_CTRL_CONN_RQST		1
-#define START_CTRL_CONN_RPLY		2
-#define STOP_CTRL_CONN_RQST		3
-#define STOP_CTRL_CONN_RPLY		4
-#define ECHO_RQST			5
-#define ECHO_RPLY			6
+#define START_CTRL_CONN_RQST            1
+#define START_CTRL_CONN_RPLY            2
+#define STOP_CTRL_CONN_RQST             3
+#define STOP_CTRL_CONN_RPLY             4
+#define ECHO_RQST                       5
+#define ECHO_RPLY                       6
 
 /* Call Management */
-#define OUT_CALL_RQST			7
-#define OUT_CALL_RPLY			8
-#define IN_CALL_RQST			9
-#define IN_CALL_RPLY			10
-#define IN_CALL_CONN			11
-#define CALL_CLR_RQST			12
-#define CALL_DISCONN_NTFY		13
+#define OUT_CALL_RQST                   7
+#define OUT_CALL_RPLY                   8
+#define IN_CALL_RQST                    9
+#define IN_CALL_RPLY                    10
+#define IN_CALL_CONN                    11
+#define CALL_CLR_RQST                   12
+#define CALL_DISCONN_NTFY               13
 
 /* Error Reporting */
-#define WAN_ERR_NTFY			14
+#define WAN_ERR_NTFY                    14
 
 /* PPP Session Control */
-#define SET_LINK_INFO			15
+#define SET_LINK_INFO                   15
 
 /* how long before a link is idle? (seconds) */
-#define IDLE_WAIT			60
+#define IDLE_WAIT                       60
 
 /* how long should we wait for an echo reply? (seconds) */
-#define MAX_ECHO_WAIT			60
+#define MAX_ECHO_WAIT                   60
 
-#define RESERVED			0x0000
+#define RESERVED                        0x0000
 
 /* Start Control Connection Reply */
-#define ASYNCHRONOUS_FRAMING		0x00000001
-#define SYNCHRONOUS_FRAMING		0x00000002
-#define ANALOG_ACCESS			0x00000001
-#define DIGITAL_ACCESS			0x00000002
+#define ASYNCHRONOUS_FRAMING            0x00000001
+#define SYNCHRONOUS_FRAMING             0x00000002
+#define ANALOG_ACCESS                   0x00000001
+#define DIGITAL_ACCESS                  0x00000002
 
 /* Our properties - we don't actually have any physical serial i/f's and only want
  * one call per client!
  */
-#define OUR_FRAMING			0x00000000
-#define OUR_BEARER			0x00000000
-#define MAX_CHANNELS			0x0001
+#define OUR_FRAMING                     0x00000000
+#define OUR_BEARER                      0x00000000
+#define MAX_CHANNELS                    0x0001
 
 /* Out Call Reply Defines */
-#define PCKT_RECV_WINDOW_SIZE		0x0001
-#define PCKT_PROCESS_DELAY		0x0000
-#define CHANNEL_ID			0x00000000
+#define PCKT_RECV_WINDOW_SIZE           0x0001
+#define PCKT_PROCESS_DELAY              0x0000
+#define CHANNEL_ID                      0x00000000
 
 /* ERROR CODES */
-#define NO_ERROR			0x00
+#define NO_ERROR                        0x00
 
 /* CALL_CLEAR RESULT CODES */
-#define LOST_CARRIER			0x01
-#define ADMIN_SHUTDOWN			0x03
-#define CALL_CLEAR_REQUEST		0x04
+#define LOST_CARRIER                    0x01
+#define ADMIN_SHUTDOWN                  0x03
+#define CALL_CLEAR_REQUEST              0x04
 
 /* RESULT CODES */
-#define CONNECTED			0x01
-#define DISCONNECTED			0x01
-#define GENERAL_ERROR			0x02	/* also for ERROR CODES, CALL CLEAR */
-#define NO_CARRIER			0x03
-#define BUSY				0x04
-#define NO_DIAL_TONE			0x05
-#define TIME_OUT			0x06
-#define DO_NOT_ACCEPT			0x07
+#define CONNECTED                       0x01
+#define DISCONNECTED                    0x01
+#define GENERAL_ERROR                   0x02    /* also for ERROR CODES, CALL CLEAR */
+#define NO_CARRIER                      0x03
+#define BUSY                            0x04
+#define NO_DIAL_TONE                    0x05
+#define TIME_OUT                        0x06
+#define DO_NOT_ACCEPT                   0x07
 
 /* CTRL CLOSE CODES */
-#define GENERAL_STOP_CTRL		0x01
-#define STOP_PROTOCOL			0x02
-#define STOP_LOCAL_SHUTDOWN		0x03
+#define GENERAL_STOP_CTRL               0x01
+#define STOP_PROTOCOL                   0x02
+#define STOP_LOCAL_SHUTDOWN             0x03
 
 /* PPTP CTRL structs */
 
 struct pptp_header {
-	u_int16_t length;		/* pptp message length incl header */
-	u_int16_t pptp_type;		/* pptp message type */
-	u_int32_t magic;		/* magic cookie */
-	u_int16_t ctrl_type;		/* control message type */
-	u_int16_t reserved0;		/* reserved */
+        u_int16_t length;               /* pptp message length incl header */
+        u_int16_t pptp_type;            /* pptp message type */
+        u_int32_t magic;                /* magic cookie */
+        u_int16_t ctrl_type;            /* control message type */
+        u_int16_t reserved0;            /* reserved */
 };
 
 struct pptp_start_ctrl_conn_rqst {
-	struct pptp_header header;	/* pptp header */
-	u_int16_t version;		/* pptp protocol version */
-	u_int16_t reserved1;		/* reserved */
-	u_int32_t framing_cap;		/* framing capabilities */
-	u_int32_t bearer_cap;		/* bearer capabilities */
-	u_int16_t max_channels;		/* maximum channels */
-	u_int16_t firmware_rev;		/* firmware revision */
-	u_int8_t hostname[MAX_HOSTNAME_SIZE];	/* hostname */
-	u_int8_t vendor[MAX_VENDOR_SIZE];	/* vendor */
+        struct pptp_header header;      /* pptp header */
+        u_int16_t version;              /* pptp protocol version */
+        u_int16_t reserved1;            /* reserved */
+        u_int32_t framing_cap;          /* framing capabilities */
+        u_int32_t bearer_cap;           /* bearer capabilities */
+        u_int16_t max_channels;         /* maximum channels */
+        u_int16_t firmware_rev;         /* firmware revision */
+        u_int8_t hostname[MAX_HOSTNAME_SIZE];   /* hostname */
+        u_int8_t vendor[MAX_VENDOR_SIZE];       /* vendor */
 };
 
 struct pptp_start_ctrl_conn_rply {
-	struct pptp_header header;	/* pptp header */
-	u_int16_t version;		/* pptp protocol version */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int32_t framing_cap;		/* framing capabilities */
-	u_int32_t bearer_cap;		/* bearer capabilities */
-	u_int16_t max_channels;		/* maximum channels */
-	u_int16_t firmware_rev;		/* firmware revision */
-	u_int8_t hostname[MAX_HOSTNAME_SIZE];	/* hostname */
-	u_int8_t vendor[MAX_VENDOR_SIZE];	/* vendor */
+        struct pptp_header header;      /* pptp header */
+        u_int16_t version;              /* pptp protocol version */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int32_t framing_cap;          /* framing capabilities */
+        u_int32_t bearer_cap;           /* bearer capabilities */
+        u_int16_t max_channels;         /* maximum channels */
+        u_int16_t firmware_rev;         /* firmware revision */
+        u_int8_t hostname[MAX_HOSTNAME_SIZE];   /* hostname */
+        u_int8_t vendor[MAX_VENDOR_SIZE];       /* vendor */
 };
 
 struct pptp_stop_ctrl_conn_rqst {
-	struct pptp_header header;	/* header */
-	u_int8_t reason;		/* reason for closing */
-	u_int8_t reserved1;		/* reserved */
-	u_int16_t reserved2;		/* reserved */
+        struct pptp_header header;      /* header */
+        u_int8_t reason;                /* reason for closing */
+        u_int8_t reserved1;             /* reserved */
+        u_int16_t reserved2;            /* reserved */
 };
 
 struct pptp_stop_ctrl_conn_rply {
-	struct pptp_header header;	/* header */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int16_t reserved1;		/* reserved */
+        struct pptp_header header;      /* header */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int16_t reserved1;            /* reserved */
 };
 
 struct pptp_echo_rqst {
-	struct pptp_header header;	/* header */
-	u_int32_t identifier;		/* value to match rply with rqst */
+        struct pptp_header header;      /* header */
+        u_int32_t identifier;           /* value to match rply with rqst */
 };
 
 struct pptp_echo_rply {
-	struct pptp_header header;	/* header */
-	u_int32_t identifier;		/* identifier of echo rqst */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int16_t reserved1;		/* reserved */
+        struct pptp_header header;      /* header */
+        u_int32_t identifier;           /* identifier of echo rqst */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int16_t reserved1;            /* reserved */
 };
 
 struct pptp_out_call_rqst {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* unique identifier to PAC-PNS pair */
-	u_int16_t call_serial;		/* session identifier */
-	u_int32_t min_bps;		/* minimum line speed */
-	u_int32_t max_bps;		/* maximum line speed */
-	u_int32_t bearer_type;		/* bearer type */
-	u_int32_t framing_type;		/* framing type */
-	u_int16_t pckt_recv_size;	/* packet recv window size */
-	u_int16_t pckt_delay;		/* packet processing delay */
-	u_int16_t phone_len;		/* phone number length */
-	u_int16_t reserved1;		/* reserved */
-	u_int8_t phone_num[64];		/* phone number */
-	u_int8_t subaddress[64];	/* additional dialing info */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* unique identifier to PAC-PNS pair */
+        u_int16_t call_serial;          /* session identifier */
+        u_int32_t min_bps;              /* minimum line speed */
+        u_int32_t max_bps;              /* maximum line speed */
+        u_int32_t bearer_type;          /* bearer type */
+        u_int32_t framing_type;         /* framing type */
+        u_int16_t pckt_recv_size;       /* packet recv window size */
+        u_int16_t pckt_delay;           /* packet processing delay */
+        u_int16_t phone_len;            /* phone number length */
+        u_int16_t reserved1;            /* reserved */
+        u_int8_t phone_num[64];         /* phone number */
+        u_int8_t subaddress[64];        /* additional dialing info */
 };
 
 struct pptp_out_call_rply {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* unique identifier to PAC-PNS pair */
-	u_int16_t call_id_peer;		/* set to call_id of the call rqst */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int16_t cause_code;		/* additional failure information */
-	u_int32_t speed;		/* actual connection speed */
-	u_int16_t pckt_recv_size;	/* packet recv window size */
-	u_int16_t pckt_delay;		/* packet processing delay */
-	u_int32_t channel_id;		/* physical channel ID */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* unique identifier to PAC-PNS pair */
+        u_int16_t call_id_peer;         /* set to call_id of the call rqst */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int16_t cause_code;           /* additional failure information */
+        u_int32_t speed;                /* actual connection speed */
+        u_int16_t pckt_recv_size;       /* packet recv window size */
+        u_int16_t pckt_delay;           /* packet processing delay */
+        u_int32_t channel_id;           /* physical channel ID */
 };
 
 struct pptp_in_call_rqst {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* unique identifier for tunnel */
-	u_int16_t call_serial;		/* session identifier */
-	u_int32_t bearer_type;		/* bearer capability */
-	u_int32_t channel_id;		/* channel ID */
-	u_int16_t dialed_len;		/* dialed length */
-	u_int16_t dialing_len;		/* dialing length */
-	u_int8_t dialed_num[64];	/* number that was dialed by the caller */
-	u_int8_t dialing_num[64];	/* the number from which the call was placed */
-	u_int8_t subaddress[64];	/* additional dialing information */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* unique identifier for tunnel */
+        u_int16_t call_serial;          /* session identifier */
+        u_int32_t bearer_type;          /* bearer capability */
+        u_int32_t channel_id;           /* channel ID */
+        u_int16_t dialed_len;           /* dialed length */
+        u_int16_t dialing_len;          /* dialing length */
+        u_int8_t dialed_num[64];        /* number that was dialed by the caller */
+        u_int8_t dialing_num[64];       /* the number from which the call was placed */
+        u_int8_t subaddress[64];        /* additional dialing information */
 };
 
 struct pptp_in_call_rply {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* unique identifier for the tunnel */
-	u_int16_t peers_call_id;	/* set to rcvd call ID */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int16_t pckt_recv_size;	/* packet recv window size */
-	u_int16_t pckt_delay;		/* packet transmit delay */
-	u_int16_t reserved1;		/* reserved */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* unique identifier for the tunnel */
+        u_int16_t peers_call_id;        /* set to rcvd call ID */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int16_t pckt_recv_size;       /* packet recv window size */
+        u_int16_t pckt_delay;           /* packet transmit delay */
+        u_int16_t reserved1;            /* reserved */
 };
 
 struct pptp_in_call_connect {
-	struct pptp_header header;	/* header */
-	u_int16_t peers_call_id;	/* set to rcvd call ID */
-	u_int16_t reserved1;		/* reserved */
-	u_int32_t speed;		/* connect speed */
-	u_int16_t pckt_recv_size;	/* packet rcvd window size */
-	u_int16_t pckt_delay;		/* packet transmit delay */
-	u_int32_t framing_type;		/* framing type */
+        struct pptp_header header;      /* header */
+        u_int16_t peers_call_id;        /* set to rcvd call ID */
+        u_int16_t reserved1;            /* reserved */
+        u_int32_t speed;                /* connect speed */
+        u_int16_t pckt_recv_size;       /* packet rcvd window size */
+        u_int16_t pckt_delay;           /* packet transmit delay */
+        u_int32_t framing_type;         /* framing type */
 };
 
 struct pptp_call_clr_rqst {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* call ID assigned by the PNS */
-	u_int16_t reserved1;		/* reserved */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* call ID assigned by the PNS */
+        u_int16_t reserved1;            /* reserved */
 };
 
 struct pptp_call_disconn_ntfy {
-	struct pptp_header header;	/* header */
-	u_int16_t call_id;		/* call ID assigned by the PAC */
-	u_int8_t result_code;		/* result code */
-	u_int8_t error_code;		/* error code */
-	u_int16_t cause_code;		/* additional disconnect info */
-	u_int16_t reserved1;		/* reserved */
-	u_int8_t call_stats[128];	/* vendor specific call stats */
+        struct pptp_header header;      /* header */
+        u_int16_t call_id;              /* call ID assigned by the PAC */
+        u_int8_t result_code;           /* result code */
+        u_int8_t error_code;            /* error code */
+        u_int16_t cause_code;           /* additional disconnect info */
+        u_int16_t reserved1;            /* reserved */
+        u_int8_t call_stats[128];       /* vendor specific call stats */
 };
 
 struct pptp_wan_err_ntfy {
-	struct pptp_header header;	/* header */
-	u_int16_t peers_call_id;	/* call ID assigned by PNS */
-	u_int16_t reserved1;		/* reserved */
-	u_int32_t crc_errors;		/* # of PPP frames rcvd with CRC errors */
-	u_int32_t framing_errors;	/* # of improperly framed PPP pckts */
-	u_int32_t hardware_overruns;	/* # of receive buffer overruns */
-	u_int32_t buff_overruns;	/* # of buffer overruns */
-	u_int32_t timeout_errors;	/* # of timeouts */
-	u_int32_t align_errors;		/* # of alignment errors */
+        struct pptp_header header;      /* header */
+        u_int16_t peers_call_id;        /* call ID assigned by PNS */
+        u_int16_t reserved1;            /* reserved */
+        u_int32_t crc_errors;           /* # of PPP frames rcvd with CRC errors */
+        u_int32_t framing_errors;       /* # of improperly framed PPP pckts */
+        u_int32_t hardware_overruns;    /* # of receive buffer overruns */
+        u_int32_t buff_overruns;        /* # of buffer overruns */
+        u_int32_t timeout_errors;       /* # of timeouts */
+        u_int32_t align_errors;         /* # of alignment errors */
 };
 
 struct pptp_set_link_info {
-	struct pptp_header header;
-	u_int16_t peers_call_id;	/* call ID assigned by PAC */
-	u_int16_t reserved1;		/* reserved */
-	u_int32_t send_accm;		/* send ACCM value the client should use */
-	u_int32_t recv_accm;		/* recv ACCM value the client should use */
+        struct pptp_header header;
+        u_int16_t peers_call_id;        /* call ID assigned by PAC */
+        u_int16_t reserved1;            /* reserved */
+        u_int32_t send_accm;            /* send ACCM value the client should use */
+        u_int32_t recv_accm;            /* recv ACCM value the client should use */
 };
 
 /* GRE and PPP structs */
 
 /* Copied from C. S. Ananian */
 
-#define HDLC_FLAG		0x7E
-#define HDLC_ESCAPE		0x7D
+#define HDLC_FLAG               0x7E
+#define HDLC_ESCAPE             0x7D
 
-#define PPTP_GRE_PROTO		0x880B
-#define PPTP_GRE_VER		0x1
+#define PPTP_GRE_PROTO          0x880B
+#define PPTP_GRE_VER            0x1
 
-#define PPTP_GRE_FLAG_C		0x80
-#define PPTP_GRE_FLAG_R		0x40
-#define PPTP_GRE_FLAG_K		0x20
-#define PPTP_GRE_FLAG_S		0x10
-#define PPTP_GRE_FLAG_A		0x80
+#define PPTP_GRE_FLAG_C         0x80
+#define PPTP_GRE_FLAG_R         0x40
+#define PPTP_GRE_FLAG_K         0x20
+#define PPTP_GRE_FLAG_S         0x10
+#define PPTP_GRE_FLAG_A         0x80
 
-#define PPTP_GRE_IS_C(f)	((f)&PPTP_GRE_FLAG_C)
-#define PPTP_GRE_IS_R(f)	((f)&PPTP_GRE_FLAG_R)
-#define PPTP_GRE_IS_K(f)	((f)&PPTP_GRE_FLAG_K)
-#define PPTP_GRE_IS_S(f)	((f)&PPTP_GRE_FLAG_S)
-#define PPTP_GRE_IS_A(f)	((f)&PPTP_GRE_FLAG_A)
+#define PPTP_GRE_IS_C(f)        ((f)&PPTP_GRE_FLAG_C)
+#define PPTP_GRE_IS_R(f)        ((f)&PPTP_GRE_FLAG_R)
+#define PPTP_GRE_IS_K(f)        ((f)&PPTP_GRE_FLAG_K)
+#define PPTP_GRE_IS_S(f)        ((f)&PPTP_GRE_FLAG_S)
+#define PPTP_GRE_IS_A(f)        ((f)&PPTP_GRE_FLAG_A)
 
 struct pptp_gre_header {
-	u_int8_t flags;		/* bitfield */
-	u_int8_t ver;		/* should be PPTP_GRE_VER (enhanced GRE) */
-	u_int16_t protocol;	/* should be PPTP_GRE_PROTO (ppp-encaps) */
-	u_int16_t payload_len;	/* size of ppp payload, not inc. gre header */
-	u_int16_t call_id;	/* peer's call_id for this session */
-	u_int32_t seq;		/* sequence number.  Present if S==1 */
-	u_int32_t ack;		/* seq number of highest packet recieved by */
-	/* sender in this session */
+        u_int8_t flags;         /* bitfield */
+        u_int8_t ver;           /* should be PPTP_GRE_VER (enhanced GRE) */
+        u_int16_t protocol;     /* should be PPTP_GRE_PROTO (ppp-encaps) */
+        u_int16_t payload_len;  /* size of ppp payload, not inc. gre header */
+        u_int16_t call_id;      /* peer's call_id for this session */
+        u_int32_t seq;          /* sequence number.  Present if S==1 */
+        u_int32_t ack;          /* seq number of highest packet recieved by */
+        /* sender in this session */
 } __attribute__((packed));
 
 /* For our call ID pairs */
@@ -318,7 +316,7 @@ struct pptp_gre_header {
 #define GET_VALUE(which, where) ((which ## _VALUE) ? ((where) & 0xffff) : ((where) >> 16))
 
 #define NOTE_VALUE(which, where, what) ((which ## _VALUE) \
-					  ? ((where) = ((where) & 0xffff0000) | (what)) \
-					  : ((where) = ((where) & 0xffff) | ((what) << 16)))
+                                          ? ((where) = ((where) & 0xffff0000) | (what)) \
+                                          : ((where) = ((where) & 0xffff) | ((what) << 16)))
 
-#endif	/* !_PPTPD_PPTPDEFS_H */
+#endif  /* !_PPTPD_PPTPDEFS_H */

+ 396 - 397
pptpgre.c

@@ -3,8 +3,6 @@
  *
  * originally by C. S. Ananian
  * Modified for PoPToP
- *
- * $Id: pptpgre.c,v 1.12 2013/02/07 00:31:15 quozl Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -12,7 +10,7 @@
 #endif
 
 #ifdef __linux__
-#define _GNU_SOURCE 1		/* broken arpa/inet.h */
+#define _GNU_SOURCE 1           /* broken arpa/inet.h */
 #endif
 
 #include "our_syslog.h"
@@ -69,184 +67,185 @@ static uint64_t time_now_usecs()
 
 int pptp_gre_init(u_int32_t call_id_pair, int pty_fd, struct in_addr *inetaddrs)
 {
-	struct sockaddr_in addr;
-	int gre_fd;
-
-	/* Open IP protocol socket */
-	gre_fd = vrf_socket(vrf, AF_INET, SOCK_RAW, PPTP_PROTO);
-	if (gre_fd < 0) {
-		syslog(LOG_ERR, "GRE: socket() failed");
-		return -1;
-	}
-
-	memset(&addr, 0, sizeof(addr));
-
-	addr.sin_family = AF_INET;
-	addr.sin_addr = inetaddrs[0];
-	addr.sin_port = 0;
-	if (bind(gre_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-		syslog(LOG_ERR, "GRE: bind() failed: %s", strerror(errno));
-		syslog(LOG_ERR, "GRE: continuing, but may not work if multi-homed");
-	}
-
-	addr.sin_family = AF_INET;
-	addr.sin_addr = inetaddrs[1];
-	addr.sin_port = 0;
-	if (connect(gre_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-		syslog(LOG_ERR, "GRE: connect() failed: %s", strerror(errno));
-		return -1;
-	}
-
-	gre.seq_sent = 0;
-	gre.ack_sent = gre.ack_recv = gre.seq_recv = 0xFFFFFFFF;
-	/* seq_recv is -1, therefore next packet expected is seq 0,
-	   to comply with RFC 2637: 'The sequence number for each
-	   user session is set to zero at session startup.' */
-				      
-	gre.call_id_pair = call_id_pair;	       /* network byte order */
-	return gre_fd;
+        struct sockaddr_in addr;
+        int gre_fd;
+
+        /* Open IP protocol socket */
+        gre_fd = vrf_socket(vrf, AF_INET, SOCK_RAW, PPTP_PROTO);
+        if (gre_fd < 0) {
+                syslog(LOG_ERR, "GRE: socket() failed");
+                return -1;
+        }
+
+        memset(&addr, 0, sizeof(addr));
+
+        addr.sin_family = AF_INET;
+        addr.sin_addr = inetaddrs[0];
+        addr.sin_port = 0;
+        if (bind(gre_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+                syslog(LOG_ERR, "GRE: bind() failed: %s", strerror(errno));
+                syslog(LOG_ERR, "GRE: continuing, but may not work if multi-homed");
+        }
+
+        addr.sin_family = AF_INET;
+        addr.sin_addr = inetaddrs[1];
+        addr.sin_port = 0;
+        if (connect(gre_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+                syslog(LOG_ERR, "GRE: connect() failed: %s", strerror(errno));
+                close(gre_fd);
+                return -1;
+        }
+
+        gre.seq_sent = 0;
+        gre.ack_sent = gre.ack_recv = gre.seq_recv = 0xFFFFFFFF;
+        /* seq_recv is -1, therefore next packet expected is seq 0,
+           to comply with RFC 2637: 'The sequence number for each
+           user session is set to zero at session startup.' */
+                                      
+        gre.call_id_pair = call_id_pair;               /* network byte order */
+        return gre_fd;
 }
 
 /* ONE blocking read per call; dispatches all packets possible */
 /* returns 0 on success, or <0 on read failure                 */
 int decaps_hdlc(int fd, int (*cb) (int cl, void *pack, unsigned len), int cl)
 {
-	static unsigned char buffer[PACKET_MAX], copy[PACKET_MAX];
-	static unsigned start = 0, end = 0;
-	static unsigned len = 0, escape = 0;
-	static u_int16_t fcs = PPPINITFCS16;
-	static unsigned char err = 0;
-	unsigned char c;
-	int status;
-
-	/* we do one read only, since it may block.  and only if the
-	 * buffer is empty (start == end)
-	 */
-
-	if (fd == -1) {
-		if(cb == NULL) {
-			/* peek mode */
-			return err ? -1 : 0;
-		} else if (!err) {
-			/* re-xmit and nothing queued */
-			syslog(LOG_ERR, "GRE: Re-xmit called with nothing queued");
-			return -1;
-		}
-	}
-
-	if (!err) {
-		/* All known data is processed.  This true unless the last
-		 * network write failed.
-		 */
-		if ((status = read(fd, buffer, sizeof(buffer))) <= 0) {
-			syslog(LOG_ERR, "GRE: read(fd=%d,buffer=%lx,len=%d) from PTY failed: status = %d error = %s%s",
-			       fd, (unsigned long) buffer,
-			       (int) sizeof(buffer),
-			       status, status ? strerror(errno) : "No error",
-			       errno != EIO ? "" : ", usually caused by unexpected termination of pppd, check option syntax and pppd logs");
-			/* FAQ: mistakes in pppd option spelling in
-			 * /etc/ppp/options.pptpd often cause EIO,
-			 * with pppd not reporting the problem to any
-			 * logs.  Termination of pppd by signal can
-			 * *also* cause this situation. -- James Cameron
-			 */
-			return -1;
-		}
-		end = status;
-		start = 0;
-	} else {
-		/* We're here because of a network write failure.  Try again.
-		 * Then do what we would do normally and enter the loop as if
-		 * just continuing the while(1).  Not sure that this ever
-		 * really happens, but since we error-check status then we
-		 * should have the code to handle an error :-)
-		 */
-		err = 0;
-		if ((status = cb(cl, copy, len)) < 0) {
-			syslog(LOG_ERR, "GRE: re-xmit failed from decaps_hdlc: %s", strerror(errno));
-			err = 1;
-			return status;	/* return error */
-		}
-		/* Great!  Let's do more! */
-		fcs = PPPINITFCS16;
-		len = 0;
-		escape = 0;
-	}
-
-	while (1) {
-		/* Infinite loop, we return when we're out of data */
-
-		/* Check if out of data */
-		if (start == end)
-			return 0;
-
-		/* Add to the packet up till the next HDLC_FLAG (start/end of
-		 * packet marker).  Copy to 'copy', un-escape and checksum as we go.
-		 */
-		while (buffer[start] != HDLC_FLAG) {
-
-			/* Dispose of 'too long' packets */
-			if (len >= PACKET_MAX) {
-				syslog(LOG_ERR, "GRE: Received too long packet from pppd.");
-				while (buffer[start] != HDLC_FLAG && start < end)
-					start++;
-				if (start < end) {
-					goto newpacket;
-				} else
-					return 0;
-			}
-			/* Read a character, un-escaping if needed */
-			if (buffer[start] == HDLC_ESCAPE && !escape)
-				escape = 1;
-			else {
-				if (escape) {
-					copy[len] = c = buffer[start] ^ 0x20;
-					escape = 0;
-				} else
-					copy[len] = c = buffer[start];
-				fcs = (fcs >> 8) ^ fcstab[(fcs ^ c) & 0xff];
-				len++;
-			}
-			start++;
-
-			/* Check if out of data */
-			if (start == end)
-				return 0;
-		}
-
-		/* Found flag.  Skip past it */
-		start++;
-
-		/* Check for over-short packets and silently discard, as per RFC1662 */
-		if ((len < 4) || (escape == 1)) {
-			/* len == 0 is possible, we generate it :-) [using HDLC_ESCAPE at
-			 * start and end of packet].  Others are worth recording.
-			 */
-			if (len && len < 4)
-				syslog(LOG_ERR, "GRE: Received too short packet from pppd.");
-			if (escape)
-				syslog(LOG_ERR, "GRE: Received bad packet from pppd.");
-			goto newpacket;
-		}
-		/* Check, then remove the 16-bit FCS checksum field */
-		if (fcs != PPPGOODFCS16) {
-			syslog(LOG_ERR, "GRE: Bad checksum from pppd.");
-			goto newpacket;
-		}
-		len -= sizeof(u_int16_t);
-
-		/* So now we have a packet of length 'len' in 'copy' */
-		if ((status = cb(cl, copy, len)) < 0) {
-			syslog(LOG_ERR, "GRE: xmit failed from decaps_hdlc: %s", strerror(errno));
-			err = 1;
-			return status;	/* return error */
-		}
-	      newpacket:
-		/* Great!  Let's do more! */
-		fcs = PPPINITFCS16;
-		len = 0;
-		escape = 0;
-	}
+        static unsigned char buffer[PACKET_MAX], copy[PACKET_MAX];
+        static unsigned start = 0, end = 0;
+        static unsigned len = 0, escape = 0;
+        static u_int16_t fcs = PPPINITFCS16;
+        static unsigned char err = 0;
+        unsigned char c;
+        int status;
+
+        /* we do one read only, since it may block.  and only if the
+         * buffer is empty (start == end)
+         */
+
+        if (fd == -1) {
+                if(cb == NULL) {
+                        /* peek mode */
+                        return err ? -1 : 0;
+                } else if (!err) {
+                        /* re-xmit and nothing queued */
+                        syslog(LOG_ERR, "GRE: Re-xmit called with nothing queued");
+                        return -1;
+                }
+        }
+
+        if (!err) {
+                /* All known data is processed.  This true unless the last
+                 * network write failed.
+                 */
+                if ((status = read(fd, buffer, sizeof(buffer))) <= 0) {
+                        syslog(LOG_ERR, "GRE: read(fd=%d,buffer=%lx,len=%d) from PTY failed: status = %d error = %s%s",
+                               fd, (unsigned long) buffer,
+                               (int) sizeof(buffer),
+                               status, status ? strerror(errno) : "No error",
+                               errno != EIO ? "" : ", usually caused by unexpected termination of pppd, check option syntax and pppd logs");
+                        /* FAQ: mistakes in pppd option spelling in
+                         * /etc/ppp/options.pptpd often cause EIO,
+                         * with pppd not reporting the problem to any
+                         * logs.  Termination of pppd by signal can
+                         * *also* cause this situation. -- James Cameron
+                         */
+                        return -1;
+                }
+                end = status;
+                start = 0;
+        } else {
+                /* We're here because of a network write failure.  Try again.
+                 * Then do what we would do normally and enter the loop as if
+                 * just continuing the while(1).  Not sure that this ever
+                 * really happens, but since we error-check status then we
+                 * should have the code to handle an error :-)
+                 */
+                err = 0;
+                if ((status = cb(cl, copy, len)) < 0) {
+                        syslog(LOG_ERR, "GRE: re-xmit failed from decaps_hdlc: %s", strerror(errno));
+                        err = 1;
+                        return status;  /* return error */
+                }
+                /* Great!  Let's do more! */
+                fcs = PPPINITFCS16;
+                len = 0;
+                escape = 0;
+        }
+
+        while (1) {
+                /* Infinite loop, we return when we're out of data */
+
+                /* Check if out of data */
+                if (start == end)
+                        return 0;
+
+                /* Add to the packet up till the next HDLC_FLAG (start/end of
+                 * packet marker).  Copy to 'copy', un-escape and checksum as we go.
+                 */
+                while (buffer[start] != HDLC_FLAG) {
+
+                        /* Dispose of 'too long' packets */
+                        if (len >= PACKET_MAX) {
+                                syslog(LOG_ERR, "GRE: Received too long packet from pppd.");
+                                while (buffer[start] != HDLC_FLAG && start < end)
+                                        start++;
+                                if (start < end) {
+                                        goto newpacket;
+                                } else
+                                        return 0;
+                        }
+                        /* Read a character, un-escaping if needed */
+                        if (buffer[start] == HDLC_ESCAPE && !escape)
+                                escape = 1;
+                        else {
+                                if (escape) {
+                                        copy[len] = c = buffer[start] ^ 0x20;
+                                        escape = 0;
+                                } else
+                                        copy[len] = c = buffer[start];
+                                fcs = (fcs >> 8) ^ fcstab[(fcs ^ c) & 0xff];
+                                len++;
+                        }
+                        start++;
+
+                        /* Check if out of data */
+                        if (start == end)
+                                return 0;
+                }
+
+                /* Found flag.  Skip past it */
+                start++;
+
+                /* Check for over-short packets and silently discard, as per RFC1662 */
+                if ((len < 4) || (escape == 1)) {
+                        /* len == 0 is possible, we generate it :-) [using HDLC_ESCAPE at
+                         * start and end of packet].  Others are worth recording.
+                         */
+                        if (len && len < 4)
+                                syslog(LOG_ERR, "GRE: Received too short packet from pppd.");
+                        if (escape)
+                                syslog(LOG_ERR, "GRE: Received bad packet from pppd.");
+                        goto newpacket;
+                }
+                /* Check, then remove the 16-bit FCS checksum field */
+                if (fcs != PPPGOODFCS16) {
+                        syslog(LOG_ERR, "GRE: Bad checksum from pppd.");
+                        goto newpacket;
+                }
+                len -= sizeof(u_int16_t);
+
+                /* So now we have a packet of length 'len' in 'copy' */
+                if ((status = cb(cl, copy, len)) < 0) {
+                        syslog(LOG_ERR, "GRE: xmit failed from decaps_hdlc: %s", strerror(errno));
+                        err = 1;
+                        return status;  /* return error */
+                }
+              newpacket:
+                /* Great!  Let's do more! */
+                fcs = PPPINITFCS16;
+                len = 0;
+                escape = 0;
+        }
 }
 
 #define seq_greater(A,B) ((A)>(B) || \
@@ -257,51 +256,51 @@ int decaps_hdlc(int fd, int (*cb) (int cl, void *pack, unsigned len), int cl)
  * as a side-effect.
  */
 #define ADD_CHAR(dest, pos, val, tmp) \
-	tmp = (val); \
-	if ((tmp<0x20) || (tmp==HDLC_FLAG) || (tmp==HDLC_ESCAPE)) { \
-		dest[pos++]=HDLC_ESCAPE; \
-		dest[pos++]=tmp^0x20; \
-	} else \
-		dest[pos++]=tmp
+        tmp = (val); \
+        if ((tmp<0x20) || (tmp==HDLC_FLAG) || (tmp==HDLC_ESCAPE)) { \
+                dest[pos++]=HDLC_ESCAPE; \
+                dest[pos++]=tmp^0x20; \
+        } else \
+                dest[pos++]=tmp
 
 /* Make stripped packet into HDLC packet */
 int encaps_hdlc(int fd, void *pack, unsigned len)
 {
-	unsigned char *source = (unsigned char *) pack;
-	/* largest expansion possible - double all + double fcs + 2 flags */
-	static unsigned char dest[2 * PACKET_MAX + 6];
-	unsigned pos = 1, i;
-	u_int16_t fcs;
-	unsigned char c;
-
-	fcs = PPPINITFCS16;
-
-	/* make sure overflow is impossible so we don't have to bounds check
-	 * in loop.  drop large packets.
-	 */
-	if (len > PACKET_MAX) {
-		syslog(LOG_ERR, "GRE: Asked to encapsulate too large packet (len = %d)", len);
-		return -1;
-	}
-	/* start character */
-	dest[0] = HDLC_FLAG;
-
-	/* escape the payload */
-	for (i = 0; i < len; i++) {
-		ADD_CHAR(dest, pos, source[i], c);
-		fcs = (fcs >> 8) ^ fcstab[(fcs ^ c) & 0xff];
-	}
-
-	fcs ^= 0xFFFF;
-
-	ADD_CHAR(dest, pos, fcs & 0xFF, c);
-	ADD_CHAR(dest, pos, fcs >> 8, c);
-
-	/* tack on the end-flag */
-	dest[pos++] = HDLC_FLAG;
-
-	/* now write this packet */
-	return write(fd, dest, pos);
+        unsigned char *source = (unsigned char *) pack;
+        /* largest expansion possible - double all + double fcs + 2 flags */
+        static unsigned char dest[2 * PACKET_MAX + 6];
+        unsigned pos = 1, i;
+        u_int16_t fcs;
+        unsigned char c;
+
+        fcs = PPPINITFCS16;
+
+        /* make sure overflow is impossible so we don't have to bounds check
+         * in loop.  drop large packets.
+         */
+        if (len > PACKET_MAX) {
+                syslog(LOG_ERR, "GRE: Asked to encapsulate too large packet (len = %d)", len);
+                return -1;
+        }
+        /* start character */
+        dest[0] = HDLC_FLAG;
+
+        /* escape the payload */
+        for (i = 0; i < len; i++) {
+                ADD_CHAR(dest, pos, source[i], c);
+                fcs = (fcs >> 8) ^ fcstab[(fcs ^ c) & 0xff];
+        }
+
+        fcs ^= 0xFFFF;
+
+        ADD_CHAR(dest, pos, fcs & 0xFF, c);
+        ADD_CHAR(dest, pos, fcs >> 8, c);
+
+        /* tack on the end-flag */
+        dest[pos++] = HDLC_FLAG;
+
+        /* now write this packet */
+        return write(fd, dest, pos);
 }
 
 #undef ADD_CHAR
@@ -309,69 +308,69 @@ int encaps_hdlc(int fd, void *pack, unsigned len)
 
 static int dequeue_gre (callback_t callback, int cl)
 {
-	pqueue_t *head;
-	int status;
-	/* process packets in the queue that either are expected or
-	   have timed out. */
-	head = pqueue_head();
-	while ( head != NULL &&
-		( (head->seq == gre.seq_recv + 1) || /* wrap-around safe */
-		  (pqueue_expiry_time(head) <= 0)
-		  )
-		) {
-		/* if it is timed out... */
-		if (head->seq != gre.seq_recv + 1 ) {  /* wrap-around safe */
-			stats.rx_lost += head->seq - gre.seq_recv - 1;
-			if (pptpctrl_debug)
-				syslog(LOG_DEBUG, 
-				       "GRE: timeout waiting for %d packets", 
-				       head->seq - gre.seq_recv - 1);        
-		}
-		if (pptpctrl_debug)
-			syslog(LOG_DEBUG, "GRE: accepting #%d from queue", 
-			       head->seq);
-		gre.seq_recv = head->seq;
-		status = callback(cl, head->packet, head->packlen);
-		pqueue_del(head);
-		if (status < 0) return status;
-		head = pqueue_head();
-	}
-	return 0;
+        pqueue_t *head;
+        int status;
+        /* process packets in the queue that either are expected or
+           have timed out. */
+        head = pqueue_head();
+        while ( head != NULL &&
+                ( (head->seq == gre.seq_recv + 1) || /* wrap-around safe */
+                  (pqueue_expiry_time(head) <= 0)
+                  )
+                ) {
+                /* if it is timed out... */
+                if (head->seq != gre.seq_recv + 1 ) {  /* wrap-around safe */
+                        stats.rx_lost += head->seq - gre.seq_recv - 1;
+                        if (pptpctrl_debug)
+                                syslog(LOG_DEBUG, 
+                                       "GRE: timeout waiting for %d packets", 
+                                       head->seq - gre.seq_recv - 1);        
+                }
+                if (pptpctrl_debug)
+                        syslog(LOG_DEBUG, "GRE: accepting #%d from queue", 
+                               head->seq);
+                gre.seq_recv = head->seq;
+                status = callback(cl, head->packet, head->packlen);
+                pqueue_del(head);
+                if (status < 0) return status;
+                head = pqueue_head();
+        }
+        return 0;
 }
 
 
 int decaps_gre(int fd, int (*cb) (int cl, void *pack, unsigned len), int cl)
 {
-	static unsigned char buffer[PACKET_MAX + 64 /*ip header */ ];
-	struct pptp_gre_header *header;
-	int status, ip_len = 0;
-
-	dequeue_gre(cb, cl);
-	if ((status = read(fd, buffer, sizeof(buffer))) <= 0) {
-		syslog(LOG_ERR, "GRE: read(fd=%d,buffer=%lx,len=%d) from network failed: status = %d error = %s",
-		       fd, (unsigned long) buffer, (int) sizeof(buffer),
-		       status, status ? strerror(errno) : "No error");
-		stats.rx_errors++;
-		return -1;
-	}
-	/* strip off IP header, if present */
-	if ((buffer[0] & 0xF0) == 0x40)
-		ip_len = (buffer[0] & 0xF) * 4;
-	header = (struct pptp_gre_header *) (buffer + ip_len);
-
-	/* verify packet (else discard) */
-	if (((ntoh8(header->ver) & 0x7F) != PPTP_GRE_VER) ||	/* version should be 1   */
-	    (ntoh16(header->protocol) != PPTP_GRE_PROTO) ||	/* GRE protocol for PPTP */
-	    PPTP_GRE_IS_C(ntoh8(header->flags)) ||	/* flag C should be clear   */
-	    PPTP_GRE_IS_R(ntoh8(header->flags)) ||	/* flag R should be clear   */
-	    (!PPTP_GRE_IS_K(ntoh8(header->flags))) ||	/* flag K should be set     */
-	    ((ntoh8(header->flags) & 0xF) != 0)) {	/* routing and recursion ctrl = 0  */
-		/* if invalid, discard this packet */
-		syslog(LOG_ERR, "GRE: Discarding packet by header check");
-		stats.rx_invalid++;
-		return 0;
-	}
-	if (header->call_id != GET_VALUE(PAC, gre.call_id_pair)) {
+        static unsigned char buffer[PACKET_MAX + 64 /*ip header */ ];
+        struct pptp_gre_header *header;
+        int status, ip_len = 0;
+
+        dequeue_gre(cb, cl);
+        if ((status = read(fd, buffer, sizeof(buffer))) <= 0) {
+                syslog(LOG_ERR, "GRE: read(fd=%d,buffer=%lx,len=%d) from network failed: status = %d error = %s",
+                       fd, (unsigned long) buffer, (int) sizeof(buffer),
+                       status, status ? strerror(errno) : "No error");
+                stats.rx_errors++;
+                return -1;
+        }
+        /* strip off IP header, if present */
+        if ((buffer[0] & 0xF0) == 0x40)
+                ip_len = (buffer[0] & 0xF) * 4;
+        header = (struct pptp_gre_header *) (buffer + ip_len);
+
+        /* verify packet (else discard) */
+        if (((ntoh8(header->ver) & 0x7F) != PPTP_GRE_VER) ||    /* version should be 1   */
+            (ntoh16(header->protocol) != PPTP_GRE_PROTO) ||     /* GRE protocol for PPTP */
+            PPTP_GRE_IS_C(ntoh8(header->flags)) ||      /* flag C should be clear   */
+            PPTP_GRE_IS_R(ntoh8(header->flags)) ||      /* flag R should be clear   */
+            (!PPTP_GRE_IS_K(ntoh8(header->flags))) ||   /* flag K should be set     */
+            ((ntoh8(header->flags) & 0xF) != 0)) {      /* routing and recursion ctrl = 0  */
+                /* if invalid, discard this packet */
+                syslog(LOG_ERR, "GRE: Discarding packet by header check");
+                stats.rx_invalid++;
+                return 0;
+        }
+        if (header->call_id != GET_VALUE(PAC, gre.call_id_pair)) {
                 /*
                  * Discard silently to allow more than one GRE tunnel from
                  * the same IP address in case clients are behind the
@@ -379,138 +378,138 @@ int decaps_gre(int fd, int (*cb) (int cl, void *pack, unsigned len), int cl)
                  *
                  * syslog(LOG_ERR, "GRE: Discarding for incorrect call");
                  */
-		return 0;
-	}
-	if (PPTP_GRE_IS_A(ntoh8(header->ver))) {	/* acknowledgement present */
-		u_int32_t ack = (PPTP_GRE_IS_S(ntoh8(header->flags))) ?
-			ntoh32(header->ack) : ntoh32(header->seq);
-			/* ack in different place if S=0 */
-
-		if (seq_greater(ack, gre.ack_recv))
-			gre.ack_recv = ack;
-
-		/* also handle sequence number wrap-around  */
-		if (WRAPPED(ack,gre.ack_recv)) gre.ack_recv = ack;
-		if (gre.ack_recv == stats.pt.seq) {
-			int rtt = time_now_usecs() - stats.pt.time;
-			stats.rtt = (stats.rtt + rtt) / 2;
-		}
-	}
-	if (PPTP_GRE_IS_S(ntoh8(header->flags))) {	/* payload present */
-		unsigned headersize = sizeof(*header);
-		unsigned payload_len = ntoh16(header->payload_len);
-		u_int32_t seq = ntoh32(header->seq);
-
-		if (!PPTP_GRE_IS_A(ntoh8(header->ver)))
-			headersize -= sizeof(header->ack);
-		/* check for incomplete packet (length smaller than expected) */
-		if (status - headersize < payload_len) {
-			stats.rx_truncated++;
-			return 0;
-		}
-		/* check for out-of-order sequence number
-		 * N.B.: some client implementations violate RFC 2637
-		 * and start their sequence numbers at 1 instead of 0,
-		 * so we have to introduce a kludge to deal with it. 
-		 * on wrap we may allow an out of order packet to pass
-		 */
-		if (seq == gre.seq_recv + 1 || seq == 1) {
-			if (pptpctrl_debug)
-				syslog(LOG_DEBUG, "GRE: accepting packet #%d", 
-				       seq);
-			stats.rx_accepted++;
-			gre.seq_recv = seq;
-			return cb(cl, buffer + ip_len + headersize, payload_len);
-		} else if (!seq_greater(seq, gre.seq_recv)) {
-			if (pptpctrl_debug)
-				syslog(LOG_DEBUG,
-				       "GRE: discarding duplicate or old packet #%d (expecting #%d)", 
-				       seq, gre.seq_recv + 1);
-			return 0;	/* discard duplicate packets */
-		} else {
-			stats.rx_buffered++;
-			if (pptpctrl_debug)
-				syslog(LOG_DEBUG,
-				       "GRE: buffering packet #%d (expecting #%d, lost or reordered)",
-				       seq, gre.seq_recv + 1);
-			pqueue_add(seq, buffer + ip_len + headersize, payload_len);
-			return 0;	/* discard out-of-order packets */
-		}
-	}
-	return 0;		/* ack, but no payload */
+                return 0;
+        }
+        if (PPTP_GRE_IS_A(ntoh8(header->ver))) {        /* acknowledgement present */
+                u_int32_t ack = (PPTP_GRE_IS_S(ntoh8(header->flags))) ?
+                        ntoh32(header->ack) : ntoh32(header->seq);
+                        /* ack in different place if S=0 */
+
+                if (seq_greater(ack, gre.ack_recv))
+                        gre.ack_recv = ack;
+
+                /* also handle sequence number wrap-around  */
+                if (WRAPPED(ack,gre.ack_recv)) gre.ack_recv = ack;
+                if (gre.ack_recv == stats.pt.seq) {
+                        int rtt = time_now_usecs() - stats.pt.time;
+                        stats.rtt = (stats.rtt + rtt) / 2;
+                }
+        }
+        if (PPTP_GRE_IS_S(ntoh8(header->flags))) {      /* payload present */
+                unsigned headersize = sizeof(*header);
+                unsigned payload_len = ntoh16(header->payload_len);
+                u_int32_t seq = ntoh32(header->seq);
+
+                if (!PPTP_GRE_IS_A(ntoh8(header->ver)))
+                        headersize -= sizeof(header->ack);
+                /* check for incomplete packet (length smaller than expected) */
+                if (status - headersize < payload_len) {
+                        stats.rx_truncated++;
+                        return 0;
+                }
+                /* check for out-of-order sequence number
+                 * N.B.: some client implementations violate RFC 2637
+                 * and start their sequence numbers at 1 instead of 0,
+                 * so we have to introduce a kludge to deal with it. 
+                 * on wrap we may allow an out of order packet to pass
+                 */
+                if (seq == gre.seq_recv + 1 || seq == 1) {
+                        if (pptpctrl_debug)
+                                syslog(LOG_DEBUG, "GRE: accepting packet #%d", 
+                                       seq);
+                        stats.rx_accepted++;
+                        gre.seq_recv = seq;
+                        return cb(cl, buffer + ip_len + headersize, payload_len);
+                } else if (!seq_greater(seq, gre.seq_recv)) {
+                        if (pptpctrl_debug)
+                                syslog(LOG_DEBUG,
+                                       "GRE: discarding duplicate or old packet #%d (expecting #%d)", 
+                                       seq, gre.seq_recv + 1);
+                        return 0;       /* discard duplicate packets */
+                } else {
+                        stats.rx_buffered++;
+                        if (pptpctrl_debug)
+                                syslog(LOG_DEBUG,
+                                       "GRE: buffering packet #%d (expecting #%d, lost or reordered)",
+                                       seq, gre.seq_recv + 1);
+                        pqueue_add(seq, buffer + ip_len + headersize, payload_len);
+                        return 0;       /* discard out-of-order packets */
+                }
+        }
+        return 0;               /* ack, but no payload */
 }
 
 
 int encaps_gre(int fd, void *pack, unsigned len)
 {
-	static union {
-		struct pptp_gre_header header;
-		unsigned char buffer[PACKET_MAX + sizeof(struct pptp_gre_header)];
-	} u;
-	unsigned header_len;
-	ssize_t status;
+        static union {
+                struct pptp_gre_header header;
+                unsigned char buffer[PACKET_MAX + sizeof(struct pptp_gre_header)];
+        } u;
+        unsigned header_len;
+        ssize_t status;
 #ifdef HAVE_WRITEV
-	struct iovec iovec[2];
+        struct iovec iovec[2];
 #endif
 
-	if(fd == -1)
-		/* peek mode */
-		return (gre.ack_sent == gre.seq_recv) ? 0 : -1;
-
-	/* package this up in a GRE shell. */
-	u.header.flags = hton8(PPTP_GRE_FLAG_K);
-	u.header.ver = hton8(PPTP_GRE_VER);
-	u.header.protocol = hton16(PPTP_GRE_PROTO);
-	u.header.payload_len = hton16(len);
-	u.header.call_id = GET_VALUE(PNS, gre.call_id_pair);
-
-	/* special case ACK with no payload */
-	if (pack == NULL) {
-		if (gre.ack_sent != gre.seq_recv) {
-			u.header.ver |= hton8(PPTP_GRE_FLAG_A);
-			u.header.payload_len = hton16(0);
-			u.header.seq = hton32(gre.seq_recv);	/* ack is in odd place because S=0 */
-			gre.ack_sent = gre.seq_recv;
-			/* don't sent ACK field, ACK is in SYN field */
-			return write(fd, u.buffer, sizeof(u.header) - sizeof(u.header.ack));
-		} else
-			return 0;	/* we don't need to send ACK */
-	}
-	/* send packet with payload */
-	u.header.flags |= hton8(PPTP_GRE_FLAG_S);
-	u.header.seq = hton32(gre.seq_sent);
-	gre.seq_sent++;
-	if (gre.ack_sent != gre.seq_recv) {	/* send ack with this message */
-		u.header.ver |= hton8(PPTP_GRE_FLAG_A);
-		u.header.ack = hton32(gre.seq_recv);
-		gre.ack_sent = gre.seq_recv;
-		header_len = sizeof(u.header);
-	} else {	/* don't send ack */
-		header_len = sizeof(u.header) - sizeof(u.header.ack);
-	}
-	if (len > PACKET_MAX) {
-		syslog(LOG_ERR, "GRE: packet is too large %d", len);
-		stats.tx_oversize++;
-		return 0;	/* drop this, it's too big */
-	}
+        if(fd == -1)
+                /* peek mode */
+                return (gre.ack_sent == gre.seq_recv) ? 0 : -1;
+
+        /* package this up in a GRE shell. */
+        u.header.flags = hton8(PPTP_GRE_FLAG_K);
+        u.header.ver = hton8(PPTP_GRE_VER);
+        u.header.protocol = hton16(PPTP_GRE_PROTO);
+        u.header.payload_len = hton16(len);
+        u.header.call_id = GET_VALUE(PNS, gre.call_id_pair);
+
+        /* special case ACK with no payload */
+        if (pack == NULL) {
+                if (gre.ack_sent != gre.seq_recv) {
+                        u.header.ver |= hton8(PPTP_GRE_FLAG_A);
+                        u.header.payload_len = hton16(0);
+                        u.header.seq = hton32(gre.seq_recv);    /* ack is in odd place because S=0 */
+                        gre.ack_sent = gre.seq_recv;
+                        /* don't sent ACK field, ACK is in SYN field */
+                        return write(fd, u.buffer, sizeof(u.header) - sizeof(u.header.ack));
+                } else
+                        return 0;       /* we don't need to send ACK */
+        }
+        /* send packet with payload */
+        u.header.flags |= hton8(PPTP_GRE_FLAG_S);
+        u.header.seq = hton32(gre.seq_sent);
+        gre.seq_sent++;
+        if (gre.ack_sent != gre.seq_recv) {     /* send ack with this message */
+                u.header.ver |= hton8(PPTP_GRE_FLAG_A);
+                u.header.ack = hton32(gre.seq_recv);
+                gre.ack_sent = gre.seq_recv;
+                header_len = sizeof(u.header);
+        } else {        /* don't send ack */
+                header_len = sizeof(u.header) - sizeof(u.header.ack);
+        }
+        if (len > PACKET_MAX) {
+                syslog(LOG_ERR, "GRE: packet is too large %d", len);
+                stats.tx_oversize++;
+                return 0;       /* drop this, it's too big */
+        }
 #ifdef HAVE_WRITEV
-	/* write header and buffer without copying. */
-	iovec[0].iov_base = u.buffer;
-	iovec[0].iov_len = header_len;
-	iovec[1].iov_base = pack;
-	iovec[1].iov_len = len;
-	status = writev(fd, iovec, 2);
+        /* write header and buffer without copying. */
+        iovec[0].iov_base = u.buffer;
+        iovec[0].iov_len = header_len;
+        iovec[1].iov_base = pack;
+        iovec[1].iov_len = len;
+        status = writev(fd, iovec, 2);
 #else
-	/* copy payload into buffer */
-	memcpy(u.buffer + header_len, pack, len);
-	/* record and increment sequence numbers */
-	/* write this baby out to the net */
-	status = write(fd, u.buffer, header_len + len);
+        /* copy payload into buffer */
+        memcpy(u.buffer + header_len, pack, len);
+        /* record and increment sequence numbers */
+        /* write this baby out to the net */
+        status = write(fd, u.buffer, header_len + len);
 #endif
-	/* if ENOBUFS, do not close the connection */
-	if ((status < 0) && (errno == ENOBUFS)) {
-		gre.seq_sent--;
-		status = 0;
-	}
-	return status;
+        /* if ENOBUFS, do not close the connection */
+        if ((status < 0) && (errno == ENOBUFS)) {
+                gre.seq_sent--;
+                status = 0;
+        }
+        return status;
 }

+ 4 - 6
pptpgre.h

@@ -2,8 +2,6 @@
  * pptpgre.h
  *
  * Functions to handle the GRE en/decapsulation
- *
- * $Id: pptpgre.h,v 1.3 2005/08/02 11:33:31 quozl Exp $
  */
 
 #ifndef _PPTPD_PPTPGRE_H
@@ -17,9 +15,9 @@ extern int encaps_gre(int fd, void *pack, unsigned len);
 extern int pptp_gre_init(u_int32_t call_id_pair, int pty_fd, struct in_addr *inetaddrs);
 
 struct gre_state {
-	u_int32_t ack_sent, ack_recv;
-	u_int32_t seq_sent, seq_recv;
-	u_int32_t call_id_pair;
+        u_int32_t ack_sent, ack_recv;
+        u_int32_t seq_sent, seq_recv;
+        u_int32_t call_id_pair;
 };
 
 extern int disable_buffer;
@@ -62,4 +60,4 @@ typedef struct gre_stats {
 
 extern gre_stats_t stats;
 
-#endif	/* !_PPTPD_PPTPGRE_H */
+#endif  /* !_PPTPD_PPTPGRE_H */

+ 291 - 293
pptpmanager.c

@@ -2,8 +2,6 @@
  * pptpmanager.c
  *
  * Manages the PoPToP sessions.
- *
- * $Id: pptpmanager.c,v 1.15 2011/05/19 00:02:50 quozl Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -11,7 +9,7 @@
 #endif
 
 #ifdef __linux__
-#define _GNU_SOURCE 1		/* broken arpa/inet.h */
+#define _GNU_SOURCE 1           /* broken arpa/inet.h */
 #endif
 
 #include "our_syslog.h"
@@ -188,10 +186,10 @@ static void sigchld_responder(int sig)
       int i;
       i = slot_find_by_pid(child);
       if (i != -1) {
-	slot_set_pid(i, 0);
-	if (pptp_debug) syslog(LOG_DEBUG, "MGR: Reaped child %d", child);
+        slot_set_pid(i, 0);
+        if (pptp_debug) syslog(LOG_DEBUG, "MGR: Reaped child %d", child);
       } else {
-	syslog(LOG_INFO, "MGR: Reaped unknown child %d", child);
+        syslog(LOG_INFO, "MGR: Reaped unknown child %d", child);
       }
     }
   }
@@ -199,198 +197,198 @@ static void sigchld_responder(int sig)
 
 int pptp_manager(int argc, char **argv)
 {
-	int firstOpen = -1;
-	int ctrl_pid;
-	socklen_t addrsize;
-
-	int hostSocket;
-	fd_set connSet;
-
-	int rc, sig_fd;
-
-	rc = sigpipe_create();
-	if (rc < 0) {
-		syslog(LOG_ERR, "MGR: unable to setup sigchld pipe!");
-		syslog_perror("sigpipe_create");
-		exit(-1);
-	}
-	
-	sigpipe_assign(SIGCHLD);
-	sigpipe_assign(SIGTERM);
-	sig_fd = sigpipe_fd();
-
-	/* openlog() not required, done in pptpd.c */
-
-	syslog(LOG_INFO, "MGR: Manager process started");
-
-	if (!pptp_delegate) {
-		syslog(LOG_INFO, "MGR: Maximum of %d connections available", 
-		       pptp_connections);
-	}
-
-	/* Connect the host socket and activate it for listening */
-	if (createHostSocket(&hostSocket) < 0) {
-		syslog(LOG_ERR, "MGR: Couldn't create host socket");
-		syslog_perror("createHostSocket");
-		exit(-1);
-	}
-
-	while (1) {
-		int max_fd;
-		FD_ZERO(&connSet);
-		if (pptp_delegate) {
-			FD_SET(hostSocket, &connSet);
-		} else {
-			firstOpen = slot_find_empty();
-			if (firstOpen == -1) {
-				syslog(LOG_ERR, "MGR: No free connection slots or IPs - no more clients can connect!");
-			} else {
-				FD_SET(hostSocket, &connSet);
-			}
-		}
-		max_fd = hostSocket;
-
-		FD_SET(sig_fd, &connSet);
-		if (max_fd < sig_fd) max_fd = sig_fd;
-
-		while (1) {
-			if (select(max_fd + 1, &connSet, NULL, NULL, NULL) != -1) break;
-			if (errno == EINTR) continue;
-			syslog(LOG_ERR, "MGR: Error with manager select()!");
-			syslog_perror("select");
-			exit(-1);
-		}
-
-		if (FD_ISSET(sig_fd, &connSet)) {	/* SIGCHLD */
-			int signum = sigpipe_read();
-			if (signum == SIGCHLD)
-				sigchld_responder(signum);
-			else if (signum == SIGTERM)
-				return signum;
-		}
-
-		if (FD_ISSET(hostSocket, &connSet)) {	/* A call came! */
-			int clientSocket;
-			struct sockaddr_in client_addr;
-
-			/* Accept call and launch PPTPCTRL */
-			addrsize = sizeof(client_addr);
-			clientSocket = accept(hostSocket, (struct sockaddr *) &client_addr, &addrsize);
+        int firstOpen = -1;
+        int ctrl_pid;
+        socklen_t addrsize;
+
+        int hostSocket;
+        fd_set connSet;
+
+        int rc, sig_fd;
+
+        rc = sigpipe_create();
+        if (rc < 0) {
+                syslog(LOG_ERR, "MGR: unable to setup sigchld pipe!");
+                syslog_perror("sigpipe_create");
+                exit(-1);
+        }
+        
+        sigpipe_assign(SIGCHLD);
+        sigpipe_assign(SIGTERM);
+        sig_fd = sigpipe_fd();
+
+        /* openlog() not required, done in pptpd.c */
+
+        syslog(LOG_INFO, "MGR: Manager process started");
+
+        if (!pptp_delegate) {
+                syslog(LOG_INFO, "MGR: Maximum of %d connections available", 
+                       pptp_connections);
+        }
+
+        /* Connect the host socket and activate it for listening */
+        if (createHostSocket(&hostSocket) < 0) {
+                syslog(LOG_ERR, "MGR: Couldn't create host socket");
+                syslog_perror("createHostSocket");
+                exit(-1);
+        }
+
+        while (1) {
+                int max_fd;
+                FD_ZERO(&connSet);
+                if (pptp_delegate) {
+                        FD_SET(hostSocket, &connSet);
+                } else {
+                        firstOpen = slot_find_empty();
+                        if (firstOpen == -1) {
+                                syslog(LOG_ERR, "MGR: No free connection slots or IPs - no more clients can connect!");
+                        } else {
+                                FD_SET(hostSocket, &connSet);
+                        }
+                }
+                max_fd = hostSocket;
+
+                FD_SET(sig_fd, &connSet);
+                if (max_fd < sig_fd) max_fd = sig_fd;
+
+                while (1) {
+                        if (select(max_fd + 1, &connSet, NULL, NULL, NULL) != -1) break;
+                        if (errno == EINTR) continue;
+                        syslog(LOG_ERR, "MGR: Error with manager select()!");
+                        syslog_perror("select");
+                        exit(-1);
+                }
+
+                if (FD_ISSET(sig_fd, &connSet)) {       /* SIGCHLD */
+                        int signum = sigpipe_read();
+                        if (signum == SIGCHLD)
+                                sigchld_responder(signum);
+                        else if (signum == SIGTERM)
+                                return signum;
+                }
+
+                if (FD_ISSET(hostSocket, &connSet)) {   /* A call came! */
+                        int clientSocket;
+                        struct sockaddr_in client_addr;
+
+                        /* Accept call and launch PPTPCTRL */
+                        addrsize = sizeof(client_addr);
+                        clientSocket = accept(hostSocket, (struct sockaddr *) &client_addr, &addrsize);
 
 #if HAVE_LIBWRAP
-			if (clientSocket != -1) {
-				struct request_info r;
-				request_init(&r, RQ_DAEMON, "pptpd", RQ_FILE, clientSocket, NULL);
-				fromhost(&r);
-				if (!hosts_access(&r)) {
-					/* send a permission denied message? this is a tcp wrapper
-					 * type deny so probably best to just drop it immediately like
-					 * this, as tcp wrappers usually do.
-					 */
-					close(clientSocket);
-					/* this would never be file descriptor 0, so use it as a error
-					 * value
-					 */
-					clientSocket = 0;
-				}
-			}
+                        if (clientSocket != -1) {
+                                struct request_info r;
+                                request_init(&r, RQ_DAEMON, "pptpd", RQ_FILE, clientSocket, NULL);
+                                fromhost(&r);
+                                if (!hosts_access(&r)) {
+                                        /* send a permission denied message? this is a tcp wrapper
+                                         * type deny so probably best to just drop it immediately like
+                                         * this, as tcp wrappers usually do.
+                                         */
+                                        close(clientSocket);
+                                        /* this would never be file descriptor 0, so use it as a error
+                                         * value
+                                         */
+                                        clientSocket = 0;
+                                }
+                        }
 #endif
-			if (clientSocket == -1) {
-				/* accept failed, but life goes on... */
-				syslog(LOG_ERR, "MGR: accept() failed");
-				syslog_perror("accept");
-			} else if (clientSocket != 0) {
-				fd_set rfds;
-				struct timeval tv;
-				struct pptp_header ph;
-
-				/* TODO: this select below prevents
+                        if (clientSocket == -1) {
+                                /* accept failed, but life goes on... */
+                                syslog(LOG_ERR, "MGR: accept() failed");
+                                syslog_perror("accept");
+                        } else if (clientSocket != 0) {
+                                fd_set rfds;
+                                struct timeval tv;
+                                struct pptp_header ph;
+
+                                /* TODO: this select below prevents
                                    other connections from being
                                    processed during the wait for the
                                    first data packet from the
                                    client. */
 
-				/*
-				 * DOS protection: get a peek at the first packet
-				 * and do some checks on it before we continue.
-				 * A 10 second timeout on the first packet seems reasonable
-				 * to me,  if anything looks sus,  throw it away.
-				 */
-
-				FD_ZERO(&rfds);
-				FD_SET(clientSocket, &rfds);
-				tv.tv_sec = pptp_stimeout;
-				tv.tv_usec = 0;
-				if (select(clientSocket + 1, &rfds, NULL, NULL, &tv) <= 0) {
-					syslog(LOG_ERR, "MGR: dropped slow initial connection");
-					close(clientSocket);
-					continue;
-				}
-
-				if (recv(clientSocket, &ph, sizeof(ph), MSG_PEEK) !=
-						sizeof(ph)) {
-					syslog(LOG_ERR, "MGR: dropped small initial connection");
-					close(clientSocket);
-					continue;
-				}
-
-				ph.length = ntohs(ph.length);
-				ph.pptp_type = ntohs(ph.pptp_type);
-				ph.magic = ntohl(ph.magic);
-				ph.ctrl_type = ntohs(ph.ctrl_type);
-
-				if (ph.length <= 0 || ph.length > PPTP_MAX_CTRL_PCKT_SIZE) {
-					syslog(LOG_WARNING, "MGR: initial packet length %d outside "
-							"(0 - %d)",  ph.length, PPTP_MAX_CTRL_PCKT_SIZE);
-					goto dos_exit;
-				}
-
-				if (ph.magic != PPTP_MAGIC_COOKIE) {
-					syslog(LOG_WARNING, "MGR: initial packet bad magic");
-					goto dos_exit;
-				}
-
-				if (ph.pptp_type != PPTP_CTRL_MESSAGE) {
-					syslog(LOG_WARNING, "MGR: initial packet has bad type");
-					goto dos_exit;
-				}
-
-				if (ph.ctrl_type != START_CTRL_CONN_RQST) {
-					syslog(LOG_WARNING, "MGR: initial packet has bad ctrl type "
-							"0x%x", ph.ctrl_type);
-		dos_exit:
-					close(clientSocket);
-					continue;
-				}
+                                /*
+                                 * DOS protection: get a peek at the first packet
+                                 * and do some checks on it before we continue.
+                                 * A 10 second timeout on the first packet seems reasonable
+                                 * to me,  if anything looks sus,  throw it away.
+                                 */
+
+                                FD_ZERO(&rfds);
+                                FD_SET(clientSocket, &rfds);
+                                tv.tv_sec = pptp_stimeout;
+                                tv.tv_usec = 0;
+                                if (select(clientSocket + 1, &rfds, NULL, NULL, &tv) <= 0) {
+                                        syslog(LOG_ERR, "MGR: dropped slow initial connection");
+                                        close(clientSocket);
+                                        continue;
+                                }
+
+                                if (recv(clientSocket, &ph, sizeof(ph), MSG_PEEK) !=
+                                                sizeof(ph)) {
+                                        syslog(LOG_ERR, "MGR: dropped small initial connection");
+                                        close(clientSocket);
+                                        continue;
+                                }
+
+                                ph.length = ntohs(ph.length);
+                                ph.pptp_type = ntohs(ph.pptp_type);
+                                ph.magic = ntohl(ph.magic);
+                                ph.ctrl_type = ntohs(ph.ctrl_type);
+
+                                if (ph.length <= 0 || ph.length > PPTP_MAX_CTRL_PCKT_SIZE) {
+                                        syslog(LOG_WARNING, "MGR: initial packet length %d outside "
+                                                        "(0 - %d)",  ph.length, PPTP_MAX_CTRL_PCKT_SIZE);
+                                        goto dos_exit;
+                                }
+
+                                if (ph.magic != PPTP_MAGIC_COOKIE) {
+                                        syslog(LOG_WARNING, "MGR: initial packet bad magic");
+                                        goto dos_exit;
+                                }
+
+                                if (ph.pptp_type != PPTP_CTRL_MESSAGE) {
+                                        syslog(LOG_WARNING, "MGR: initial packet has bad type");
+                                        goto dos_exit;
+                                }
+
+                                if (ph.ctrl_type != START_CTRL_CONN_RQST) {
+                                        syslog(LOG_WARNING, "MGR: initial packet has bad ctrl type "
+                                                        "0x%x", ph.ctrl_type);
+                dos_exit:
+                                        close(clientSocket);
+                                        continue;
+                                }
 
 #ifndef HAVE_FORK
-				switch (ctrl_pid = vfork()) {
+                                switch (ctrl_pid = vfork()) {
 #else
-				switch (ctrl_pid = fork()) {
+                                switch (ctrl_pid = fork()) {
 #endif
-				case -1:	/* error */
-					syslog(LOG_ERR, "MGR: fork() failed launching " PPTP_CTRL_BIN);
-					close(clientSocket);
-					break;
-
-				case 0:	/* child */
-					close(hostSocket);
-					if (pptp_debug)
-						syslog(LOG_DEBUG, "MGR: Launching " PPTP_CTRL_BIN " to handle client");
-					connectCall(clientSocket, !pptp_delegate ? firstOpen : 0);
-					_exit(1);
-					/* NORETURN */
-				default:	/* parent */
-					close(clientSocket);
-					unique_call_id += MAX_CALLS_PER_TCP_LINK;
-					if (!pptp_delegate)
-						slot_set_pid(firstOpen, ctrl_pid);
-					break;
-				}
-			}
-		}		/* FD_ISSET(hostSocket, &connSet) */
-	}			/* while (1) */
-}				/* pptp_manager() */
+                                case -1:        /* error */
+                                        syslog(LOG_ERR, "MGR: fork() failed launching " PPTP_CTRL_BIN);
+                                        close(clientSocket);
+                                        break;
+
+                                case 0: /* child */
+                                        close(hostSocket);
+                                        if (pptp_debug)
+                                                syslog(LOG_DEBUG, "MGR: Launching " PPTP_CTRL_BIN " to handle client");
+                                        connectCall(clientSocket, !pptp_delegate ? firstOpen : 0);
+                                        _exit(1);
+                                        /* NORETURN */
+                                default:        /* parent */
+                                        close(clientSocket);
+                                        unique_call_id += MAX_CALLS_PER_TCP_LINK;
+                                        if (!pptp_delegate)
+                                                slot_set_pid(firstOpen, ctrl_pid);
+                                        break;
+                                }
+                        }
+                }               /* FD_ISSET(hostSocket, &connSet) */
+        }                       /* while (1) */
+}                               /* pptp_manager() */
 
 /*
  * Author: Kevin Thayer
@@ -409,44 +407,44 @@ int pptp_manager(int argc, char **argv)
  */
 static int createHostSocket(int *hostSocket)
 {
-	int opt = 1;
-	struct sockaddr_in address;
+        int opt = 1;
+        struct sockaddr_in address;
 #ifdef HAVE_GETSERVBYNAME
-	struct servent *serv;
+        struct servent *serv;
 #endif
 
-	/* create the master socket and check it worked */
-	if ((*hostSocket = vrf_socket(vrf, AF_INET, SOCK_STREAM, 0)) == 0)
-		return -1;
-
-	/* set master socket to allow daemon to be restarted with connections active  */
-	if (setsockopt(*hostSocket, SOL_SOCKET, SO_REUSEADDR,
-		       (char *) &opt, sizeof(opt)) < 0)
-		return -2;
-
-	/* set up socket */
-	memset(&address, 0, sizeof(address));
-	address.sin_family = AF_INET;
-	if(bindaddr)
-		address.sin_addr.s_addr = inet_addr(bindaddr);
-	else
-		address.sin_addr.s_addr = INADDR_ANY;
+        /* create the master socket and check it worked */
+        if ((*hostSocket = vrf_socket(vrf, AF_INET, SOCK_STREAM, 0)) <= 0)
+                return -1;
+
+        /* set master socket to allow daemon to be restarted with connections active  */
+        if (setsockopt(*hostSocket, SOL_SOCKET, SO_REUSEADDR,
+                       (char *) &opt, sizeof(opt)) < 0)
+                return -2;
+
+        /* set up socket */
+        memset(&address, 0, sizeof(address));
+        address.sin_family = AF_INET;
+        if(bindaddr)
+                address.sin_addr.s_addr = inet_addr(bindaddr);
+        else
+                address.sin_addr.s_addr = INADDR_ANY;
 #ifdef HAVE_GETSERVBYNAME
-	if ((serv = getservbyname("pptp", "tcp")) != NULL) {
-		address.sin_port = serv->s_port;
-	} else
+        if ((serv = getservbyname("pptp", "tcp")) != NULL) {
+                address.sin_port = serv->s_port;
+        } else
 #endif
-		address.sin_port = htons(PPTP_PORT);
+                address.sin_port = htons(PPTP_PORT);
 
-	/* bind the socket to the pptp port */
-	if (bind(*hostSocket, (struct sockaddr *) &address, sizeof(address)) < 0)
-		return -3;
+        /* bind the socket to the pptp port */
+        if (bind(*hostSocket, (struct sockaddr *) &address, sizeof(address)) < 0)
+                return -3;
 
-	/* minimal backlog to avoid DoS */
-	if (listen(*hostSocket, 3) < 0)
-		return -4;
+        /* minimal backlog to avoid DoS */
+        if (listen(*hostSocket, 3) < 0)
+                return -4;
 
-	return 0;
+        return 0;
 }
 
 /*
@@ -459,93 +457,93 @@ static void connectCall(int clientSocket, int clientNumber)
 {
 
 #define NUM2ARRAY(array, num) snprintf(array, sizeof(array), "%d", num)
-	
-	char *ctrl_argv[16];	/* arguments for launching 'pptpctrl' binary */
+        
+        char *ctrl_argv[16];    /* arguments for launching 'pptpctrl' binary */
 
-	int pptpctrl_argc = 0;	/* count the number of arguments sent to pptpctrl */
+        int pptpctrl_argc = 0;  /* count the number of arguments sent to pptpctrl */
 
-	/* lame strings to hold passed args. */
-	char ctrl_debug[2];
-	char ctrl_noipparam[2];
-	char pppdoptfile_argv[2];
-	char speedgiven_argv[2];
-	extern char **environ;
+        /* lame strings to hold passed args. */
+        char ctrl_debug[2];
+        char ctrl_noipparam[2];
+        char pppdoptfile_argv[2];
+        char speedgiven_argv[2];
+        extern char **environ;
 
-	char callid_argv[16];
+        char callid_argv[16];
 
-	/*
-	 * Launch the CTRL manager binary; we send it some information such as
-	 * speed and option file on the command line.
-	 */
+        /*
+         * Launch the CTRL manager binary; we send it some information such as
+         * speed and option file on the command line.
+         */
 
-	ctrl_argv[pptpctrl_argc++] = PPTP_CTRL_BIN "                                ";
+        ctrl_argv[pptpctrl_argc++] = PPTP_CTRL_BIN "                                ";
 
-	/* Pass socket as stdin */
-	if (clientSocket != 0) {
-		dup2(clientSocket, 0);
-		close(clientSocket);
-	}
+        /* Pass socket as stdin */
+        if (clientSocket != 0) {
+                dup2(clientSocket, 0);
+                close(clientSocket);
+        }
 
-	/* get argv set up */
-	NUM2ARRAY(ctrl_debug, pptp_debug ? 1 : 0);
-	ctrl_debug[1] = '\0';
-	ctrl_argv[pptpctrl_argc++] = ctrl_debug;
+        /* get argv set up */
+        NUM2ARRAY(ctrl_debug, pptp_debug ? 1 : 0);
+        ctrl_debug[1] = '\0';
+        ctrl_argv[pptpctrl_argc++] = ctrl_debug;
 
-	NUM2ARRAY(ctrl_noipparam, pptp_noipparam ? 1 : 0);
-	ctrl_noipparam[1] = '\0';
-	ctrl_argv[pptpctrl_argc++] = ctrl_noipparam;
+        NUM2ARRAY(ctrl_noipparam, pptp_noipparam ? 1 : 0);
+        ctrl_noipparam[1] = '\0';
+        ctrl_argv[pptpctrl_argc++] = ctrl_noipparam;
 
 #ifdef VRF
-	ctrl_argv[pptpctrl_argc++] = vrf ? vrf : "";
+        ctrl_argv[pptpctrl_argc++] = vrf ? vrf : "";
 #endif
 
-	/* optionfile = TRUE or FALSE; so the CTRL manager knows whether to load a non-standard options file */
-	NUM2ARRAY(pppdoptfile_argv, pppdoptstr ? 1 : 0);
-	pppdoptfile_argv[1] = '\0';
-	ctrl_argv[pptpctrl_argc++] = pppdoptfile_argv;
-	if (pppdoptstr) {
-		/* send the option filename so the CTRL manager can launch pppd with this alternate file */
-		ctrl_argv[pptpctrl_argc++] = pppdoptstr;
-	}
-	/* tell the ctrl manager whether we were given a speed */
-	NUM2ARRAY(speedgiven_argv, speedstr ? 1 : 0);
-	speedgiven_argv[1] = '\0';
-	ctrl_argv[pptpctrl_argc++] = speedgiven_argv;
-	if (speedstr) {
-		/* send the CTRL manager the speed of the connection so it can fire pppd at that speed */
-		ctrl_argv[pptpctrl_argc++] = speedstr;
-	}
-	if (pptp_delegate) {
-		/* no local or remote address to specify */
-		ctrl_argv[pptpctrl_argc++] = "0";
-		ctrl_argv[pptpctrl_argc++] = "0";
-	} else {
-		/* specify local & remote addresses for this call */
-		ctrl_argv[pptpctrl_argc++] = "1";
-		ctrl_argv[pptpctrl_argc++] = slot_get_local(clientNumber);
-		ctrl_argv[pptpctrl_argc++] = "1";
-		ctrl_argv[pptpctrl_argc++] = slot_get_remote(clientNumber);
-	}
-
-	/* our call id to be included in GRE packets the client
-	 * will send to us */
-	NUM2ARRAY(callid_argv, unique_call_id);
-	ctrl_argv[pptpctrl_argc++] = callid_argv;
-
-	/* pass path to ppp binary */
-	ctrl_argv[pptpctrl_argc++] = ppp_binary;
-
-	/* pass logwtmp flag */
-	ctrl_argv[pptpctrl_argc++] = pptp_logwtmp ? "1" : "0";
-
-	/* note: update pptpctrl.8 if the argument list format is changed */
-
-	/* terminate argv array with a NULL */
-	ctrl_argv[pptpctrl_argc] = NULL;
-	pptpctrl_argc++;
-
-	/* ok, args are setup: invoke the call handler */
-	execve(PPTP_CTRL_BIN, ctrl_argv, environ);
-	syslog(LOG_ERR, "MGR: Failed to exec " PPTP_CTRL_BIN "!");
-	_exit(1);
+        /* optionfile = TRUE or FALSE; so the CTRL manager knows whether to load a non-standard options file */
+        NUM2ARRAY(pppdoptfile_argv, pppdoptstr ? 1 : 0);
+        pppdoptfile_argv[1] = '\0';
+        ctrl_argv[pptpctrl_argc++] = pppdoptfile_argv;
+        if (pppdoptstr) {
+                /* send the option filename so the CTRL manager can launch pppd with this alternate file */
+                ctrl_argv[pptpctrl_argc++] = pppdoptstr;
+        }
+        /* tell the ctrl manager whether we were given a speed */
+        NUM2ARRAY(speedgiven_argv, speedstr ? 1 : 0);
+        speedgiven_argv[1] = '\0';
+        ctrl_argv[pptpctrl_argc++] = speedgiven_argv;
+        if (speedstr) {
+                /* send the CTRL manager the speed of the connection so it can fire pppd at that speed */
+                ctrl_argv[pptpctrl_argc++] = speedstr;
+        }
+        if (pptp_delegate) {
+                /* no local or remote address to specify */
+                ctrl_argv[pptpctrl_argc++] = "0";
+                ctrl_argv[pptpctrl_argc++] = "0";
+        } else {
+                /* specify local & remote addresses for this call */
+                ctrl_argv[pptpctrl_argc++] = "1";
+                ctrl_argv[pptpctrl_argc++] = slot_get_local(clientNumber);
+                ctrl_argv[pptpctrl_argc++] = "1";
+                ctrl_argv[pptpctrl_argc++] = slot_get_remote(clientNumber);
+        }
+
+        /* our call id to be included in GRE packets the client
+         * will send to us */
+        NUM2ARRAY(callid_argv, unique_call_id);
+        ctrl_argv[pptpctrl_argc++] = callid_argv;
+
+        /* pass path to ppp binary */
+        ctrl_argv[pptpctrl_argc++] = ppp_binary;
+
+        /* pass logwtmp flag */
+        ctrl_argv[pptpctrl_argc++] = pptp_logwtmp ? "1" : "0";
+
+        /* note: update pptpctrl.8 if the argument list format is changed */
+
+        /* terminate argv array with a NULL */
+        ctrl_argv[pptpctrl_argc] = NULL;
+        pptpctrl_argc++;
+
+        /* ok, args are setup: invoke the call handler */
+        execve(PPTP_CTRL_BIN, ctrl_argv, environ);
+        syslog(LOG_ERR, "MGR: Failed to exec " PPTP_CTRL_BIN "!");
+        _exit(1);
 }

+ 1 - 3
pptpmanager.h

@@ -2,8 +2,6 @@
  * pptpmanager.h
  *
  * Manager function prototype.
- *
- * $Id: pptpmanager.h,v 1.2 2005/12/29 09:59:49 quozl Exp $
  */
 
 #ifndef _PPTPD_PPTPSERVER_H
@@ -21,4 +19,4 @@ char *slot_get_remote(int i);
 
 extern int pptp_manager(int argc, char **argv);
 
-#endif	/* !_PPTPD_PPTPSERVER_H */
+#endif  /* !_PPTPD_PPTPSERVER_H */

+ 23 - 22
pqueue.c

@@ -41,23 +41,23 @@ static int pqueue_alloc(int seq, unsigned char *packet, int packlen, pqueue_t **
 
       if (newent->capacity >= packlen) {
 
- 	/* unlink from freelist */
-	if (pq_freelist_head == newent) 
-	  pq_freelist_head = newent->next;
+        /* unlink from freelist */
+        if (pq_freelist_head == newent) 
+          pq_freelist_head = newent->next;
 
-	if (newent->prev) 
-	  newent->prev->next = newent->next;
+        if (newent->prev) 
+          newent->prev->next = newent->next;
 
-	if (newent->next) 
-	  newent->next->prev = newent->prev;
+        if (newent->next) 
+          newent->next->prev = newent->prev;
 
-	if (pq_freelist_head) 
-	  pq_freelist_head->prev = NULL;
+        if (pq_freelist_head) 
+          pq_freelist_head->prev = NULL;
 
-	break;
-      }	/* end if capacity >= packlen */
+        break;
+      } /* end if capacity >= packlen */
     } /* end for */
-	
+        
     /* nothing found? Take first and reallocate it */
     if (NULL == newent) {
 
@@ -65,15 +65,15 @@ static int pqueue_alloc(int seq, unsigned char *packet, int packlen, pqueue_t **
       pq_freelist_head = pq_freelist_head->next;
 
       if (pq_freelist_head) 
-	pq_freelist_head->prev = NULL;
+        pq_freelist_head->prev = NULL;
 
       DEBUG_CMD(syslog(LOG_DEBUG, "realloc capacity %d to %d",newent->capacity, packlen););
 
       newent->packet = (unsigned char *)realloc(newent->packet, packlen);
 
       if (!newent->packet) {
-	syslog(LOG_WARNING, "error reallocating packet: %s", strerror(errno));
-	return -1;
+        syslog(LOG_WARNING, "error reallocating packet: %s", strerror(errno));
+        return -1;
       }
       newent->capacity = packlen;
     }
@@ -136,20 +136,21 @@ int pqueue_add (int seq, unsigned char *packet, int packlen) {
     if (point->seq == seq) {
       // queue already contains this packet
       syslog(LOG_WARNING, "discarding duplicate packet %d", seq);
+      pqueue_del(newent);
       return -1;
     }
     if (point->seq > seq) {
       // gone too far: point->seq > seq and point->prev->seq < seq
       if (point->prev) {
-	// insert between point->prev and point
-	DEBUG_CMD(syslog(LOG_DEBUG, "adding %d between %d and %d", 
-		      seq, point->prev->seq, point->seq););
+        // insert between point->prev and point
+        DEBUG_CMD(syslog(LOG_DEBUG, "adding %d between %d and %d", 
+                      seq, point->prev->seq, point->seq););
 
-	point->prev->next = newent;
+        point->prev->next = newent;
       } else {
-	// insert at head of queue, before point
-	DEBUG_CMD(syslog(LOG_DEBUG, "adding %d before %d", seq, point->seq););
-	pq_head = newent;
+        // insert at head of queue, before point
+        DEBUG_CMD(syslog(LOG_DEBUG, "adding %d before %d", seq, point->seq););
+        pq_head = newent;
       }
       newent->prev = point->prev; // will be NULL, at head of queue
       newent->next = point;

+ 0 - 196
tools/client-test

@@ -1,196 +0,0 @@
-#!/bin/sh
-#
-#   $Id: client-test,v 1.2 2006/02/13 23:50:44 quozl Exp $
-#
-#   client-test, PPTP lab test script
-#   Copyright (C) 2005  James Cameron (quozl@us.netrek.org)
-#
-#   This program is free software; you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program; if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#
-# --
-#
-#   Creates many tunnels from a test client to a single server.
-#   Test sequence is as follows
-#
-#   1.  on server ... set it to listen on chosen network address
-#       ip addr add 10.9.0.3/16 dev eth0
-#       and edit /etc/hosts.allow to cover range "ALL: 10.9.0.0/16"
-#
-#   2.  on client ... run pptpconfig to define a tunnel named test
-#
-#   3.  run "./client-test start" to create the tunnels
-#
-#   4.  run "./client-test status" to test the tunnels with ping
-#
-#   5.  run "./client-test stop" to stop the tunnels
-#
-
-# number of sets of tunnels to create
-MAX_C=10
-
-# number of tunnels in each set
-MAX_D=100
-
-# network address prefix for test network
-PREFIX=10.9
-
-# address of server on test network
-SERVER=10.9.0.3
-
-# create a virtual interface for the address
-function if_up {
-    ip addr add ${PREFIX}.${2}.${3}/16 dev eth0 && echo -n .
-}
-
-# delete the virtual interface
-function if_down {
-    ip addr del ${PREFIX}.${2}.${3}/16 dev eth0 2>/dev/null && echo -n .
-# expected error on 2.6.8 ...
-# RTNETLINK answers: Cannot assign requested address
-}
-
-# create a tunnel from the virtual interface to the server
-function tu_up {
-    pppd call test updetach linkname test-${1} \
-        pty "pptp ${SERVER} --nolaunchpppd --localbind=${PREFIX}.${2}.${3}"
-}
-
-# create a tunnel from the virtual interface to the server
-function tu_up_fast {
-    pppd call test linkname test-${1} \
-        pty "pptp ${SERVER} --nolaunchpppd --localbind=${PREFIX}.${2}.${3}"
-    echo -n .
-    sleep 0.1
-}
-
-# delete a tunnel previously created
-function tu_down {
-    if test -f /var/run/ppp-test-${1}.pid; then
-	kill `head -1 /var/run/ppp-test-${1}.pid` && echo -n .
-    fi
-}
-
-# start tunnels rapidly and fill up available memory until swap free
-# starts to be scarce
-function filler {
-    if_up $1 $2 $3
-    tu_up_fast $1 $2 $3
-    swapfree=`grep SwapFree /proc/meminfo |awk '{print $2}'`
-    until test ${swapfree} -gt 4096; do
-	echo -n -
-	sleep 1
-    done
-}
-
-# check the state of a tunnel slot
-function state {
-    echo -n "slot ${1} "
-    if ! test -f /var/run/ppp-test-${1}.pid; then
-	echo -n "(missing) "
-    else
-	pid=`head -1 /var/run/ppp-test-${1}.pid`
-	echo -n "pid ${pid} "
-	if ! kill -0 ${pid} 2>/dev/null; then
-	    echo -n "(missing) "
-	fi
-	iface=`tail -1 /var/run/ppp-test-${1}.pid`
-	echo -n "iface ${iface} "
-	if ! ip addr show dev ${iface} 1>/dev/null 2>/dev/null; then
-	    echo -n "(missing) "
-	fi
-	inet=`ip addr show dev ${iface}|egrep --only-matching "inet [0-9.]*"|awk '{print $2}'`
-	echo -n "inet ${inet} "
-	peer=`ip addr show dev ${iface}|egrep --only-matching "peer [0-9.]*"|awk '{print $2}'`
-	echo -n "peer ${peer} "
-	avg=`/bin/ping -c 1 ${peer} 2>/dev/null | grep "rtt min" | cut -f6 -d/`
-	if test -z "${avg}"; then
-	    echo -n "ping (missing) "
-	else
-	    echo -n "ping ${avg} "
-	fi
-    fi
-    echo
-}
-
-# general purpose iteration function to call a handler (above) once
-# for each slot in the test set.  Handler receives slot number, then
-# the fragments of IP address a.b.C.D.
-function iterate {
-    x=1
-    for c in `seq ${MAX_C}`; do
-	for d in `seq ${MAX_D}`; do
-	    ${1} ${x} ${c} ${d}
-	    x=`expr ${x} + 1`
-	done
-    done
-}
-
-# start the test
-function start {
-    iterate if_up
-    echo
-    iterate tu_up
-    echo
-}
-
-# start slow test
-function fill {
-    iterate filler
-    echo
-}
-
-# stop the test
-function stop {
-    iterate tu_down
-    echo
-    sleep 10
-    iterate if_down
-    echo
-}
-
-# check status of test
-function status {
-    iterate state
-}
-
-# main dispatcher
-case "$1" in
-    start)
-	start
-	break
-    ;;
-    fill)
-	fill
-	break
-    ;;
-    stop)
-	stop
-	break
-    ;;
-    restart)
-	stop
-	start
-	break
-    ;;
-    status)
-        status
-	break
-    ;;
-    *)
-	echo "Usage: ${0} start|fill|stop|restart|status" 1>&2
-	exit 1
-    ;;
-esac
-

+ 0 - 42
tools/confmod.sh

@@ -1,42 +0,0 @@
-#!/bin/bash
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-# Your copy is available at: http://www.gnu.org/licenses/gpl.html
-
-TEMP=$(locate /etc/conf.modules); if [ -n "$TEMP" ]; then ln -s /etc/conf.modules /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias ppp ppp_generic")
-if [ -n "$TEMP" ]; then
-        grep -v "alias ppp ppp_generic" /etc/modules.conf > /etc/modules.conf1;
-        mv -f /etc/modules.conf1 /etc/modules.conf
-fi
-TEMP=$(cat /etc/modules.conf | grep "alias char-major-108 off")
-if [ -n "$TEMP" ]; then
-        grep -v "alias char-major-108 off" /etc/modules.conf > /etc/modules.conf1;
-        mv -f /etc/modules.conf1 /etc/modules.conf
-fi
-TEMP=$(cat /etc/modules.conf | grep "alias char-major-108 ppp_generic")
-if [ -z "$TEMP" ]; then echo "alias char-major-108 ppp_generic" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias ppp-compress-18 ppp_mppe")
-if [ -z "$TEMP" ]; then echo "alias ppp-compress-18 ppp_mppe" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias ppp-compress-21 bsd_comp")
-if [ -z "$TEMP" ]; then echo "alias ppp-compress-21 bsd_comp" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias ppp-compress-24 ppp_deflate")
-if [ -z "$TEMP" ]; then echo "alias ppp-compress-24 ppp_deflate" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias ppp-compress-26 ppp_deflate")
-if [ -z "$TEMP" ]; then echo "alias ppp-compress-26 ppp_deflate" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias tty-ldisc-3 ppp_async")
-if [ "$TEMP" = "" ]; then echo "alias tty-ldisc-3 ppp_async" >> /etc/modules.conf; fi
-TEMP=$(cat /etc/modules.conf | grep "alias tty-ldisc-14 ppp_synctty")
-if [ -z "$TEMP" ]; then echo "alias tty-ldisc-14 ppp_synctty" >> /etc/modules.conf; fi

+ 0 - 45
tools/vpnwho.pl

@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-# NOTE: superceded by --logwtmp feature, see ../README.logwtmp
-#
-# By Jason Collins-Webb (jason@rbaltd.co.uk)
-# usage: vpnwho
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-# Your copy is available at: http://www.gnu.org/licenses/gpl.html
-#
-
-$TDateM = substr(`/bin/date +"%b"`, 0, -1);
-$TDateD = substr(`/bin/date +"%e"`, 0, -1);
-$whoson = `/bin/ps -eo pid,bsdstart,cmd|/bin/grep "pptpd \\["`;
-if ($whoson ne "") {
-@logons = split(/\n/, $whoson);
-foreach $l (@logons) {
-  if ($l =~ /(\d+)\s+(\d+:\d+).*\[(\d+\.\d+\.\d+\.\d+)\]/) {
-    $PID = $1+1;
-    $IP = $3;
-    $STIME = $2;
-    open MESSAGES, "</var/log/messages";
-    while(<MESSAGES>){
-      if ($_ =~ /.*\spppd\[$PID\]:\s+MSCHAP-v2\s.*\s(.+\\)*(.+)$/i) {
-          $User = lc($2);
-          }
-     }
-     close MESSAGES;
-  print "Current VPN connection from $User ($IP), started at $STIME\n";
-  }
-}
-} else {
-print "There are no current VPN connections.\n";
-}