Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IPv6 supported ppp from freebsd-current.

  • Loading branch information...
commit c5bbdc6be248a5ac1ba7f701fdb92ca2b4b95be9 1 parent 24a41b7
sumikawa authored
Showing with 15,553 additions and 3,288 deletions.
  1. +26 −16 freebsd4/usr.sbin/ppp/Makefile
  2. +33 −1 freebsd4/usr.sbin/ppp/README.changes
  3. +28 −0 freebsd4/usr.sbin/ppp/README.devel
  4. +378 −0 freebsd4/usr.sbin/ppp/README.nat
  5. +1 −1  freebsd4/usr.sbin/ppp/acf.c
  6. +16 −12 freebsd4/usr.sbin/ppp/arp.c
  7. +26 −19 freebsd4/usr.sbin/ppp/arp.h
  8. +26 −18 freebsd4/usr.sbin/ppp/async.c
  9. +235 −0 freebsd4/usr.sbin/ppp/atm.c
  10. +35 −0 freebsd4/usr.sbin/ppp/atm.h
  11. +31 −20 freebsd4/usr.sbin/ppp/auth.c
  12. +25 −17 freebsd4/usr.sbin/ppp/auth.h
  13. +163 −270 freebsd4/usr.sbin/ppp/bundle.c
  14. +19 −20 freebsd4/usr.sbin/ppp/bundle.h
  15. +1 −1  freebsd4/usr.sbin/ppp/cbcp.c
  16. +221 −43 freebsd4/usr.sbin/ppp/ccp.c
  17. +57 −21 freebsd4/usr.sbin/ppp/ccp.h
  18. +195 −42 freebsd4/usr.sbin/ppp/chap.c
  19. +28 −18 freebsd4/usr.sbin/ppp/chap.h
  20. +308 −23 freebsd4/usr.sbin/ppp/chap_ms.c
  21. +40 −19 freebsd4/usr.sbin/ppp/chap_ms.h
  22. +6 −1 freebsd4/usr.sbin/ppp/chat.c
  23. +1 −1  freebsd4/usr.sbin/ppp/chat.h
  24. +517 −217 freebsd4/usr.sbin/ppp/command.c
  25. +25 −17 freebsd4/usr.sbin/ppp/command.h
  26. +33 −26 freebsd4/usr.sbin/ppp/datalink.c
  27. +1 −1  freebsd4/usr.sbin/ppp/datalink.h
  28. +12 −4 freebsd4/usr.sbin/ppp/deflate.c
  29. +4 −5 freebsd4/usr.sbin/ppp/defs.c
  30. +31 −20 freebsd4/usr.sbin/ppp/defs.h
  31. +1 −1  freebsd4/usr.sbin/ppp/descriptor.h
  32. +64 −42 freebsd4/usr.sbin/ppp/ether.c
  33. +2 −1  freebsd4/usr.sbin/ppp/exec.c
  34. +188 −304 freebsd4/usr.sbin/ppp/filter.c
  35. +36 −50 freebsd4/usr.sbin/ppp/filter.h
  36. +57 −33 freebsd4/usr.sbin/ppp/fsm.c
  37. +27 −19 freebsd4/usr.sbin/ppp/fsm.h
  38. +28 −19 freebsd4/usr.sbin/ppp/hdlc.c
  39. +25 −17 freebsd4/usr.sbin/ppp/hdlc.h
  40. +2 −1  freebsd4/usr.sbin/ppp/i4b.c
  41. +1 −1  freebsd4/usr.sbin/ppp/id.c
  42. +1 −1  freebsd4/usr.sbin/ppp/id.h
  43. +376 −232 freebsd4/usr.sbin/ppp/iface.c
  44. +15 −15 freebsd4/usr.sbin/ppp/iface.h
  45. +355 −308 freebsd4/usr.sbin/ppp/ip.c
  46. +33 −24 freebsd4/usr.sbin/ppp/ip.h
  47. +402 −391 freebsd4/usr.sbin/ppp/ipcp.c
  48. +34 −70 freebsd4/usr.sbin/ppp/ipcp.h
  49. +618 −0 freebsd4/usr.sbin/ppp/ipv6cp.c
  50. +81 −0 freebsd4/usr.sbin/ppp/ipv6cp.h
  51. +149 −44 freebsd4/usr.sbin/ppp/lcp.c
  52. +29 −17 freebsd4/usr.sbin/ppp/lcp.h
  53. +12 −3 freebsd4/usr.sbin/ppp/link.c
  54. +1 −1  freebsd4/usr.sbin/ppp/link.h
  55. +27 −5 freebsd4/usr.sbin/ppp/log.c
  56. +15 −14 freebsd4/usr.sbin/ppp/log.h
  57. +25 −23 freebsd4/usr.sbin/ppp/lqr.c
  58. +25 −17 freebsd4/usr.sbin/ppp/lqr.h
  59. +67 −30 freebsd4/usr.sbin/ppp/main.c
  60. +25 −18 freebsd4/usr.sbin/ppp/main.h
  61. +47 −31 freebsd4/usr.sbin/ppp/mbuf.c
  62. +67 −55 freebsd4/usr.sbin/ppp/mbuf.h
  63. +109 −44 freebsd4/usr.sbin/ppp/mp.c
  64. +4 −3 freebsd4/usr.sbin/ppp/mp.h
  65. +737 −0 freebsd4/usr.sbin/ppp/mppe.c
  66. +33 −0 freebsd4/usr.sbin/ppp/mppe.h
  67. +132 −7 freebsd4/usr.sbin/ppp/nat_cmd.c
  68. +29 −3 freebsd4/usr.sbin/ppp/nat_cmd.h
  69. +550 −0 freebsd4/usr.sbin/ppp/ncp.c
  70. +101 −0 freebsd4/usr.sbin/ppp/ncp.h
  71. +972 −0 freebsd4/usr.sbin/ppp/ncpaddr.c
  72. +108 −0 freebsd4/usr.sbin/ppp/ncpaddr.h
  73. +32 −21 freebsd4/usr.sbin/ppp/pap.c
  74. +25 −17 freebsd4/usr.sbin/ppp/pap.h
  75. +36 −9 freebsd4/usr.sbin/ppp/physical.c
  76. +4 −1 freebsd4/usr.sbin/ppp/physical.h
  77. +5,780 −0 freebsd4/usr.sbin/ppp/ppp.8.m4
  78. +13 −4 freebsd4/usr.sbin/ppp/pred.c
  79. +25 −17 freebsd4/usr.sbin/ppp/pred.h
  80. +29 −4 freebsd4/usr.sbin/ppp/probe.c
  81. +7 −2 freebsd4/usr.sbin/ppp/probe.h
  82. +9 −4 freebsd4/usr.sbin/ppp/prompt.c
  83. +6 −1 freebsd4/usr.sbin/ppp/prompt.h
  84. +1 −1  freebsd4/usr.sbin/ppp/proto.c
  85. +31 −15 freebsd4/usr.sbin/ppp/proto.h
  86. +219 −36 freebsd4/usr.sbin/ppp/radius.c
  87. +23 −3 freebsd4/usr.sbin/ppp/radius.h
  88. +420 −179 freebsd4/usr.sbin/ppp/route.c
  89. +46 −32 freebsd4/usr.sbin/ppp/route.h
  90. +184 −61 freebsd4/usr.sbin/ppp/server.c
  91. +19 −7 freebsd4/usr.sbin/ppp/server.h
  92. +22 −10 freebsd4/usr.sbin/ppp/sig.c
  93. +6 −1 freebsd4/usr.sbin/ppp/slcompress.c
  94. +1 −1  freebsd4/usr.sbin/ppp/slcompress.h
  95. +30 −23 freebsd4/usr.sbin/ppp/systems.c
  96. +25 −18 freebsd4/usr.sbin/ppp/systems.h
  97. +37 −25 freebsd4/usr.sbin/ppp/tcp.c
  98. +186 −0 freebsd4/usr.sbin/ppp/tcpmss.c
  99. +29 −0 freebsd4/usr.sbin/ppp/tcpmss.h
  100. +1 −1  freebsd4/usr.sbin/ppp/throughput.c
  101. +1 −1  freebsd4/usr.sbin/ppp/throughput.h
  102. +25 −19 freebsd4/usr.sbin/ppp/timer.c
  103. +25 −17 freebsd4/usr.sbin/ppp/timer.h
  104. +18 −8 freebsd4/usr.sbin/ppp/tty.c
  105. +16 −8 freebsd4/usr.sbin/ppp/tun.c
  106. +2 −2 freebsd4/usr.sbin/ppp/tun.h
  107. +57 −24 freebsd4/usr.sbin/ppp/udp.c
  108. +31 −19 freebsd4/usr.sbin/ppp/vjcomp.c
View
42 freebsd4/usr.sbin/ppp/Makefile
@@ -1,15 +1,13 @@
-# $FreeBSD: src/usr.sbin/ppp/Makefile,v 1.73.2.2 2000/08/19 09:29:59 brian Exp $
+# $FreeBSD: src/usr.sbin/ppp/Makefile,v 1.91 2001/08/14 16:05:50 brian Exp $
PROG= ppp
+MAN= ppp.8
SRCS= acf.c arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c \
command.c datalink.c deflate.c defs.c exec.c filter.c fsm.c hdlc.c \
- iface.c ip.c ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c \
- mbuf.c mp.c pap.c physical.c pred.c probe.c prompt.c proto.c route.c \
- server.c sig.c slcompress.c sync.c systems.c tcp.c throughput.c \
- timer.c tty.c tun.c udp.c vjcomp.c
-CFLAGS+=-Wall
-LDADD+= -lcrypt -lmd -lutil -lz
-DPADD+= ${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
+ iface.c ip.c ipcp.c ipv6cp.c iplist.c lcp.c link.c log.c lqr.c main.c \
+ mbuf.c mp.c ncp.c ncpaddr.c pap.c physical.c pred.c probe.c prompt.c \
+ proto.c route.c server.c sig.c slcompress.c sync.c systems.c tcp.c \
+ tcpmss.c throughput.c timer.c tty.c tun.c udp.c vjcomp.c
.if defined(NOSUID) || defined(PPP_NOSUID)
BINMODE=554
.else
@@ -17,12 +15,24 @@ BINMODE=4554
BINOWN= root
.endif
BINGRP= network
-MAN8= ppp.8
+M4FLAGS=
+
+LDADD= -lcrypt -lmd -lutil -lz
+DPADD= ${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
+
+.SUFFIXES: .8 .8.m4
+
+.8.m4.8:
+ m4 ${M4FLAGS} ${.IMPSRC} >${.TARGET}
.if defined(RELEASE_CRUNCH)
CFLAGS+=-DRELEASE_CRUNCH
.endif
+.if defined(PPP_CONFDIR) && !empty(PPP_CONFDIR)
+CFLAGS+=-DPPP_CONFDIR=\"${PPP_CONFDIR}\"
+.endif
+
.if defined(NOKLDLOAD)
CFLAGS+=-DNOKLDLOAD
.endif
@@ -41,6 +51,12 @@ DPADD+= ${LIBALIAS}
.endif
.endif
+.if defined(NOATM) || defined(RELEASE_CRUNCH)
+CFLAGS+=-DNOATM
+.else
+SRCS+= atm.c
+.endif
+
.if defined(NOSUID) || defined(PPP_NOSUID)
CFLAGS+=-DNOSUID
.else
@@ -52,7 +68,7 @@ SRCS+= id.c
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE) && !defined(NO_OPENSSL) && !defined(RELEASE_CRUNCH)
DISTRIBUTION=crypto
CFLAGS+=-DHAVE_DES
-SRCS+= chap_ms.c
+SRCS+= chap_ms.c mppe.c
LDADD+= -lcrypto
DPADD+= ${LIBCRYPTO}
.endif
@@ -82,13 +98,7 @@ DPADD+= ${LIBNETGRAPH}
.endif
.if defined(RELEASE_CRUNCH)
-# We must create these objects because crunchgen will link them,
-# and we don't want any unused symbols to spoil the final link.
CFLAGS+=-DNONAT -DNORADIUS -DNOI4B -DNOSUID
-OBJS+= chap_ms.o id.o nat_cmd.o radius.o
-chap_ms.o id.o nat_cmd.o radius.o:
- >null_${.PREFIX}.c
- cc -c -o ${.TARGET} null_${.PREFIX}.c
.endif
.include <bsd.prog.mk>
View
34 freebsd4/usr.sbin/ppp/README.changes
@@ -1,4 +1,29 @@
-$FreeBSD: src/usr.sbin/ppp/README.changes,v 1.16.2.3 2000/08/19 09:29:59 brian Exp $
+Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
+ based on work by Eivind Eklund <perhaps@yes.no>,
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+$FreeBSD: src/usr.sbin/ppp/README.changes,v 1.23 2001/06/04 14:38:28 brian Exp $
This file summarises changes made to ppp that effect
its configuration.
@@ -106,3 +131,10 @@ o The ``!'' at the start of chat scripts and authkey can be made literal
(rather than meaning execute) by doubling it to ``!!''.
o MP autoload throughput measurements are now based on the maximum of input
and output averages rather than on the total.
+o When only one link is open in MP mode, MP link level compression is not
+ open and the peer MRU >= the peer MRRU, ppp sends outbound traffic as
+ PROTO_IP traffic rather than PROTO_MP.
+o MSCHAPv2 is now accepted by default. If you don't wish to negotiate
+ this, you must explicitly deny it.
+o MPPE is enabled and accepted by default (although deflate and predictor1
+ are preferred.
View
28 freebsd4/usr.sbin/ppp/README.devel
@@ -1,3 +1,31 @@
+Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
+ based on work by Eivind Eklund <perhaps@yes.no>,
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+$FreeBSD: src/usr.sbin/ppp/README.devel,v 1.5 2001/06/04 14:38:28 brian Exp $
+
+This file summarises changes made to ppp that effect
This program was originally written by Toshiharu OHNO <tony-o@iij.ad.jp>,
and was submitted to FreeBSD-2.0.5 by Atsushi Murai <amurai@spec.co.jp>.
The original version was usually referred to as iij-ppp.
View
378 freebsd4/usr.sbin/ppp/README.nat
@@ -0,0 +1,378 @@
+Copyright (c) 2001 Charles Mott <cmott@scientech.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+$FreeBSD: src/usr.sbin/ppp/README.nat,v 1.4 2001/06/04 14:38:28 brian Exp $
+
+User PPP NAT (Packet Aliasing)
+
+
+
+0. Contents
+ 1. Background
+ 2. Setup
+ 3. New commands in ppp
+ 4. Future Work
+ 5. Authors / Acknowledgements
+ 6. Revision History for Aliasing Code
+
+
+
+1. Background
+
+User mode ppp has embedded NAT (Network Address Translation) code.
+Enabling this, either by the "-nat" command line option or the
+"nat enable yes" command in a ppp.conf file, makes the ppp host
+automatically NAT IP packets forwarded from a local network, making
+them appear to come from the ppp host machine. Incoming packets
+from the outside world are then appropriately de-NAT'd.
+
+The process of NAT'ing involves both the IP address and the TCP or UDP
+port numbers. ICMP echo and timestamp packets are natted by their id
+numbers. ICMP error messages can be properly directed by examining the
+fragment of the offending packet which is contained in the body of the
+message.
+
+This software was specifically meant to support users who have
+unregistered, private address IP networks (e.g. 192.168.0.x or 10.0.0.x
+addresses). The ppp host can act as a gateway for these networks, and
+computers on the local area net will have some degree of Internet access
+without the need for a registered IP address. Additionally, there will
+be no need for an Internet service provider to maintain routing tables
+for the local area network.
+
+A disadvantage of NAT is that machines on the local network,
+behind the ppp host, are not visible from the outside world. They can
+establish TCP connections and make UDP inquiries (such as domain name
+service requests) but the connections seem to come from the ppp host
+itself. There is, in effect, a partial firewall. Of course, if this is
+what you want, the disadvantage becomes an advantage.
+
+A second disadvantage is that "IP encoding" protocols, which send IP
+address or port information within the data stream, are not supported
+for the cases where exception code exists. This implementation has
+workarounds for FTP and IRC DCC, the most well known of the IP encoding
+protocols. This frees users from depending on using the ftp passive
+mode and avoiding IRC DCC sends, as is sometimes the case with other
+masquerading solutions.
+
+The implementation supports all standard, non-encoding TCP and UDP protocols.
+Examples of these protocols are http, gopher and telnet. The standard UDP
+mode of Real-Audio is not presently supported, but the TCP mode does work
+correctly.
+
+The NAT code also handles many ICMP messages. In particular,
+ping and traceroute are supported.
+
+
+
+2. Packet Aliasing Setup
+
+It is recommended that users first verify correct ppp operation without
+NAT enabled. This will confirm that the ppp.conf file is
+properly set up and that there are no ppp problems. Then start ppp with
+the "-nat" option on the command line. The user should verify that
+the ppp host can correctly connect to the Internet in NAT
+mode. Finally, check that machines on the private network can access
+the Internet.
+
+The NAT software handles all packets, whether they come from
+the host or another computer on the local area network. Thus, a correctly
+operating ppp host indicates that the software should work properly for
+other computers on the private network.
+
+If the ppp host can access the Internet, but other computers on the local
+network cannot, check that IP forwarding is enabled on the ppp host. Also,
+verify that the other computers use this machine as a gateway. Of course,
+you should also verify that machines within the local area network
+communicate properly. A common error is inconsistent subnet addresses
+and masks.
+
+
+
+3. New commands in ppp
+
+In order to control NAT behaviour in a simple manner (no need for
+recompilation), a new command has been added to ppp: nat. This
+is in addition to the -nat command line option. System managers and
+more experienced users may prefer to use the ppp command syntax
+within the ppp.conf file. The nat command also allows NAT
+behaviour to be more precisely specified.
+
+The decision to add a command instead of extending 'set' or 'option' was
+to make obvious that these options only work when NAT is enabled.
+
+The syntax for 'nat' is
+
+ ppp> nat option [yes|no]
+
+where option is given by one of the following templates.
+
+
+ - nat enable [yes|no] (default no)
+
+Enable NAT functionality. If disabled, no other NAT
+options will have any effect. You should usually enable NAT
+before routing any packets over the link; good points are in the
+initial script or right before adding a route. If you do not always
+want NAT, consider using the -nat option to ppp instead of this
+command.
+
+
+ - nat deny_incoming [yes|no] (default yes)
+
+Set to "yes" to disable all incoming connections. This just drops
+connections to, for example, ftp, telnet or web servers. The NAT
+mechanism prevents these connections. Technically, this option denies
+all incoming TCP and UDP requests, making the NAT software a
+fairly efficient one-way firewall. The default is no, which will allow
+all incoming connections to telnetd, ftpd, etc.
+
+
+ - nat log [yes|no]
+
+Controls logging of NAT link creation to "/var/log/alias.log" - this
+is usually only useful if debugging a setup, to see if the bug is in
+the PPP NATing. The debugging information is fairly limited, listing
+the number of NAT links open for different protocols.
+
+
+ - nat same_ports [yes|no] (default yes)
+
+When a connection is being established going through the NAT
+routines, it will normally have its port number changed to allow the
+NAT code to track it. If same_ports is enabled, the NAT
+software attempts to keep the connection's source port unchanged.
+This will allow rsh, RPC and other specialised protocols to work
+_most of the time_, at least on the host machine. Please, do not
+report this being unstable as a bug - it is a result of the way
+NAT has to work. TCP/IP was intended to have one IP address
+per machine.
+
+
+ - nat use_sockets [yes|no] (default yes)
+
+This is a fairly obscure option. For the most part, the NAT
+software does not have to allocate system sockets when it chooses a
+NAT port number. Under very specific circumstances, FTP data
+connections (which don't know the remote port number, though it is
+usually 20) and IRC DCC send (which doesn't know either the address or
+the port from which the connection will come), there can potentially be
+some interference with an open server socket having the same port number
+on the ppp host machine. This possibility for interference only exists
+until the TCP connection has been acknowledged on both sides. The safe
+option is yes, though fewer system resources are consumed by specifying
+no.
+
+
+ - nat unregistered_only [yes|no] (default no)
+
+NAT normally remaps all packets coming from the local area
+network to the ppp host machine address. Set this option to only map
+addresses from the following standard ranges for private, unregistered
+addresses:
+
+ 10.0.0.0 -> 10.255.255.255
+ 172.16.0.0 -> 172.31.255.255
+ 192.168.0.0 -> 192.168.255.255 */
+
+In the instance that there is a subnet of public addresses and another
+subnet of private addresses being routed by the ppp host, then only the
+packets on the private subnet will be NAT'd.
+
+
+- nat port <proto> <local addr>:<port> <nat port>
+
+This command allows incoming traffic to <nat port> on the host
+machine to be redirected to a specific machine and port on the
+local area network. One example of this would be:
+
+ nat port tcp 192.168.0.4:telnet 8066
+
+All traffic to port 8066 of the ppp host would then be sent to
+the telnet port (23) of machine 192.168.0.4. Port numbers
+can either be designated numerically or by symbolic names
+listed in /etc/services. Similarly, addresses can be either
+in dotted quad notation or in /etc/hosts.
+
+
+- nat addr <local addr> <public addr>
+
+This command allows traffic for a public IP address to be
+redirected to a machine on the local network. This function
+is known as "static NAT". An address assignment of 0 refers
+to the default address of the ppp host. Normally static
+NAT is useful if your ISP has allocated a small block of
+IP addresses to the user, but it can even be used in the
+case of a single, dynamically allocated IP address:
+
+ nat addr 10.0.0.8 0
+
+The above command would redirect all incoming traffic to
+machine 10.0.0.8.
+
+If several address NATs specify the same public address
+as follows
+
+ nat addr 192.168.0.2 public_addr
+ nat addr 192.168.0.3 public_addr
+ nat addr 192.168.0.4 public_addr
+
+then incoming traffic will be directed to the last
+translated local address (192.168.0.4), but outgoing
+traffic to the first two addresses will still be NAT'd
+to the specified public address.
+
+
+
+4. Future Work
+
+What is called NAT here has been variously called masquerading, packet
+aliasing and transparent proxying by others. It is an extremely useful
+function to many users, but it is also necessarily imperfect. The
+occasional IP-encoding protocols always need workarounds (hacks).
+Users who are interested in supporting new IP-encoding protocols
+can follow the examples of alias_ftp.c and alias_irc.c.
+
+ICMP error messages are currently handled only in the incoming direction.
+A handler needs to be added to correctly NAT outgoing error messages.
+
+IRC and FTP exception handling make reasonable, though not strictly correct
+assumptions, about how IP encoded messages will appear in the control
+stream. Programmers may wish to consider how to make this process more
+robust.
+
+The NAT engine (alias.c, alias_db.c, alias_ftp.c, alias_irc.c
+and alias_util.c) runs in user space, and is intended to be both portable
+and reusable for interfaces other than ppp. To access the basic engine
+only requires four simple function calls (initialisation, communication of
+host address, outgoing NAT and incoming de-NATing).
+
+
+
+5. Authors / Acknowledgements
+
+Charles Mott (cmott@srv.net) <versions 1.0 - 1.8, 2.0, 2.1>
+Eivind Eklund (perhaps@yes.no) <versions 1.8b - 1.9, new ppp commands>
+
+Listed below, in chronological order, are individuals who have provided
+valuable comments and/or debugging assistance.
+
+ Gary Roberts
+ Tom Torrance
+ Reto Burkhalter
+ Martin Renters
+ Brian Somers
+ Paul Traina
+ Ari Suutari
+ J. Fortes
+ Andrzej Bialeki
+
+
+
+6. Revision History for Aliasing Code
+
+Version 1.0: August 11, 1996 (cjm)
+
+Version 1.1: August 20, 1996 (cjm)
+ PPP host accepts incoming connections for ports 0 to 1023.
+
+Version 1.2: September 7, 1996 (cjm)
+ Fragment handling error in alias_db.c corrected.
+
+Version 1.3: September 15, 1996 (cjm)
+ - Generalised mechanism for handling incoming connections
+ (no more 0 to 1023 restriction).
+ - Increased ICMP support (will handle traceroute now).
+ - Improved TCP close connection logic.
+
+Version 1.4: September 16, 1996
+ Can't remember (this version only lasted a day -- cjm).
+
+Version 1.5: September 17, 1996 (cjm)
+ Corrected error in handling incoming UDP packets
+ with zero checksum.
+
+Version 1.6: September 18, 1996
+ Simplified ICMP data storage. Will now handle
+ tracert from Win95 as well as FreeBSD traceroute.
+
+Version 1.7: January 9, 1997 (cjm)
+ - Reduced malloc() activity for ICMP echo and
+ timestamp requests.
+ - Added handling for out-of-order IP fragments.
+ - Switched to differential checksum computation
+ for IP headers (TCP, UDP and ICMP checksums
+ were already differential).
+ - Accepts FTP data connections from other than
+ port 20. This allows one ftp connections
+ from two hosts which are both running packet
+ aliasing.
+
+Version 1.8: January 14, 1997 (cjm)
+ - Fixed data type error in function StartPoint()
+ in alias_db.c (this bug did not exist before v1.7)
+
+Version 1.8b: January 16, 1997 (Eivind Eklund <perhaps@yes.no>)
+ - Upgraded base PPP version to be the source code from
+ FreeBSD 2.1.6, with additional security patches. This
+ version should still be possible to run on 2.1.5, though -
+ I've run it with a 2.1.5 kernel without problems.
+ (Update done with the permission of cjm)
+
+Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>)
+ - Added support for IRC DCC (ee)
+ - Changed the aliasing routines to use ANSI style throughout -
+ minor API changes for integration with other programs than PPP (ee)
+ - Changed the build process, making all options switchable
+ from the Makefile (ee)
+ - Fixed minor security hole in alias_ftp.c for other applications
+ of the aliasing software. Hole could _not_ manifest in
+ PPP+pktAlias, but could potentially manifest in other
+ applications of the aliasing. (ee)
+ - Connections initiated from packet aliasing host machine will
+ not have their port number aliased unless it conflicts with
+ an aliasing port already being used. (There is an option to
+ disable this for debugging) (cjm)
+ - Sockets will be allocated in cases where there might be
+ port interference with the host machine. This can be disabled
+ in cases where the ppp host will be acting purely as a
+ masquerading router and not generate any traffic of its own.
+ (cjm)
+
+Version 2.0: March, 1997 (cjm)
+ - Incoming packets which are not recognised by the packet
+ aliasing engine are now completely dropped in ip.c.
+ - Aliasing links are cleared when a host interface address
+ changes (due to re-dial and dynamic address allocation).
+ - PacketAliasPermanentLink() API added.
+ - Option for only aliasing private, unregistered IP addresses
+ added.
+ - Substantial rework to the aliasing lookup engine.
+
+Version 2.1: May, 1997 (cjm)
+ - Continuing rework to the aliasing lookup engine to support
+ multiple incoming addresses and static NAT.
+ - Now supports outgoing as well as incoming ICMP error messages/
+ - PPP commands to support address and port redirection.
+
View
2  freebsd4/usr.sbin/ppp/acf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/ppp/acf.c,v 1.4.2.1 2000/08/19 09:29:59 brian Exp $
+ * $FreeBSD: src/usr.sbin/ppp/acf.c,v 1.5 2000/07/19 02:10:30 brian Exp $
*/
#include <sys/types.h>
View
28 freebsd4/usr.sbin/ppp/arp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $FreeBSD: src/usr.sbin/ppp/arp.c,v 1.37.2.1 2000/03/21 10:22:58 brian Exp $
+ * $FreeBSD: src/usr.sbin/ppp/arp.c,v 1.41 2001/08/14 16:05:50 brian Exp $
*
*/
@@ -57,13 +57,16 @@
#include "slcompress.h"
#include "lqr.h"
#include "hdlc.h"
+#include "ncpaddr.h"
#include "ipcp.h"
-#include "filter.h"
+#include "ipv6cp.h"
#include "descriptor.h"
#include "lcp.h"
#include "ccp.h"
#include "link.h"
#include "mp.h"
+#include "ncp.h"
+#include "filter.h"
#ifndef NORADIUS
#include "radius.h"
#endif
@@ -104,7 +107,7 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
*/
memset(&arpmsg, 0, sizeof arpmsg);
- if (!get_ether_addr(s, addr, &arpmsg.hwa)) {
+ if (!arp_EtherAddr(s, addr, &arpmsg.hwa, 0)) {
log_Printf(LogWARN, "%s: Cannot determine ethernet address for proxy ARP\n",
inet_ntoa(addr));
return 0;
@@ -144,7 +147,6 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
int
arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
{
-
return (arp_ProxySub(bundle, addr, 1, s));
}
@@ -154,7 +156,6 @@ arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
int
arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
{
-
return (arp_ProxySub(bundle, addr, 0, s));
}
@@ -178,8 +179,9 @@ arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
* Get the hardware address of an interface on the same subnet as our local
* address.
*/
- if (!get_ether_addr(s, addr, &dls.sdl)) {
- log_Printf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
+ if (!arp_EtherAddr(s, addr, &dls.sdl, 1)) {
+ log_Printf(LOG_PHASE_BIT, "Cannot determine ethernet address for "
+ "proxy ARP\n");
return 0;
}
arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
@@ -219,12 +221,13 @@ arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
/*
- * get_ether_addr - get the hardware address of an interface on the
+ * arp_EtherAddr - get the hardware address of an interface on the
* the same subnet as ipaddr.
*/
int
-get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
+arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr,
+ int verbose)
{
int mib[6], skip;
size_t needed;
@@ -242,7 +245,7 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
mib[5] = 0;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
- log_Printf(LogERROR, "get_ether_addr: sysctl: estimate: %s\n",
+ log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n",
strerror(errno));
return 0;
}
@@ -298,8 +301,9 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) ==
(ipaddr.s_addr & netmask->sin_addr.s_addr)) {
- log_Printf(LogPHASE, "Found interface %.*s for %s\n",
- dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
+ log_Printf(verbose ? LogPHASE : LogDEBUG,
+ "Found interface %.*s for %s\n", dl->sdl_alen,
+ dl->sdl_data, inet_ntoa(ipaddr));
memcpy(hwaddr, dl, dl->sdl_len);
free(buf);
return 1;
View
45 freebsd4/usr.sbin/ppp/arp.h
@@ -1,24 +1,31 @@
-/*
- * User Process PPP
+/*-
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
+ * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
+ * Internet Initiative Japan, Inc (IIJ)
+ * All rights reserved.
*
- * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Internet Initiative Japan, Inc. The name of the
- * IIJ may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD: src/usr.sbin/ppp/arp.h,v 1.9 1999/08/28 01:18:15 peter Exp $
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
+ * $FreeBSD: src/usr.sbin/ppp/arp.h,v 1.11 2001/07/31 15:19:07 brian Exp $
*/
struct sockaddr_dl;
@@ -26,4 +33,4 @@ struct bundle;
extern int arp_ClearProxy(struct bundle *, struct in_addr, int);
extern int arp_SetProxy(struct bundle *, struct in_addr, int);
-extern int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
+extern int arp_EtherAddr(int, struct in_addr, struct sockaddr_dl *, int);
View
44 freebsd4/usr.sbin/ppp/async.c
@@ -1,25 +1,33 @@
-/*
- * PPP Async HDLC Module
- *
- * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+/*-
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
+ * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
+ * Internet Initiative Japan, Inc (IIJ)
+ * All rights reserved.
*
- * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Internet Initiative Japan, Inc. The name of the
- * IIJ may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD: src/usr.sbin/ppp/async.c,v 1.23 1999/12/20 20:29:40 brian Exp $
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
+ * $FreeBSD: src/usr.sbin/ppp/async.c,v 1.24 2001/06/13 21:52:15 brian Exp $
*/
+
#include <sys/types.h>
#include <string.h>
View
235 freebsd4/usr.sbin/ppp/atm.c
@@ -0,0 +1,235 @@
+/*-
+ * Copyright (c) 2000 Jakob Stoklund Olesen <stoklund@taxidriver.dk>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/atm.c,v 1.4 2001/06/18 14:59:30 brian Exp $
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netnatm/natm.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <sys/uio.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include "layer.h"
+#include "defs.h"
+#include "mbuf.h"
+#include "log.h"
+#include "timer.h"
+#include "lqr.h"
+#include "hdlc.h"
+#include "throughput.h"
+#include "fsm.h"
+#include "lcp.h"
+#include "ccp.h"
+#include "link.h"
+#include "async.h"
+#include "descriptor.h"
+#include "physical.h"
+#include "main.h"
+#include "atm.h"
+
+/* String identifying PPPoA */
+#define PPPOA "PPPoA"
+#define PPPOA_LEN (sizeof(PPPOA) - 1)
+
+struct atmdevice {
+ struct device dev; /* What struct physical knows about */
+};
+
+#define device2atm(d) ((d)->type == ATM_DEVICE ? (struct atmdevice *)d : NULL)
+
+int
+atm_DeviceSize(void)
+{
+ return sizeof(struct atmdevice);
+}
+
+static ssize_t
+atm_Sendto(struct physical *p, const void *v, size_t n)
+{
+ ssize_t ret = write(p->fd, v, n);
+ if (ret < 0) {
+ log_Printf(LogDEBUG, "atm_Sendto(%ld): %s\n", (long)n, strerror(errno));
+ return ret;
+ }
+ return ret;
+}
+
+static ssize_t
+atm_Recvfrom(struct physical *p, void *v, size_t n)
+{
+ ssize_t ret = read(p->fd, (char*)v, n);
+ if (ret < 0) {
+ log_Printf(LogDEBUG, "atm_Recvfrom(%ld): %s\n", (long)n, strerror(errno));
+ return ret;
+ }
+ return ret;
+}
+
+static void
+atm_Free(struct physical *p)
+{
+ struct atmdevice *dev = device2atm(p->handler);
+
+ free(dev);
+}
+
+static void
+atm_device2iov(struct device *d, struct iovec *iov, int *niov,
+ int maxiov, int *auxfd, int *nauxfd)
+{
+ int sz = physical_MaxDeviceSize();
+
+ iov[*niov].iov_base = realloc(d, sz);
+ if (iov[*niov].iov_base == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
+ AbortProgram(EX_OSERR);
+ }
+ iov[*niov].iov_len = sz;
+ (*niov)++;
+}
+
+static const struct device baseatmdevice = {
+ ATM_DEVICE,
+ "atm",
+ 0,
+ { CD_NOTREQUIRED, 0 },
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ atm_Free,
+ atm_Recvfrom,
+ atm_Sendto,
+ atm_device2iov,
+ NULL,
+ NULL
+};
+
+struct device *
+atm_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
+ int maxiov, int *auxfd, int *nauxfd)
+{
+ if (type == ATM_DEVICE) {
+ struct atmdevice *dev = (struct atmdevice *)iov[(*niov)++].iov_base;
+
+ dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */
+ if (dev == NULL) {
+ log_Printf(LogALERT, "Failed to allocate memory: %d\n",
+ (int)(sizeof *dev));
+ AbortProgram(EX_OSERR);
+ }
+
+ /* Refresh function pointers etc */
+ memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev);
+
+ physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
+ return &dev->dev;
+ }
+
+ return NULL;
+}
+
+static struct atmdevice *
+atm_CreateDevice(struct physical *p, const char *iface, unsigned vpi,
+ unsigned vci)
+{
+ struct atmdevice *dev;
+ struct sockaddr_natm sock;
+
+ if ((dev = calloc(1, sizeof *dev)) == NULL) {
+ log_Printf(LogWARN, "%s: Cannot allocate an atm device: %s\n",
+ p->link.name, strerror(errno));
+ return NULL;
+ }
+
+ sock.snatm_len = sizeof sock;
+ sock.snatm_family = AF_NATM;
+ strncpy(sock.snatm_if, iface, IFNAMSIZ);
+ sock.snatm_vpi = vpi;
+ sock.snatm_vci = vci;
+
+ log_Printf(LogPHASE, "%s: Connecting to %s:%u.%u\n", p->link.name,
+ iface, vpi, vci);
+
+ p->fd = socket(PF_NATM, SOCK_DGRAM, PROTO_NATMAAL5);
+ if (p->fd >= 0) {
+ log_Printf(LogDEBUG, "%s: Opened atm socket %s\n", p->link.name,
+ p->name.full);
+ if (connect(p->fd, (struct sockaddr *)&sock, sizeof sock) == 0)
+ return dev;
+ else
+ log_Printf(LogWARN, "%s: connect: %s\n", p->name.full, strerror(errno));
+ } else
+ log_Printf(LogWARN, "%s: socket: %s\n", p->name.full, strerror(errno));
+
+ close(p->fd);
+ p->fd = -1;
+ free(dev);
+
+ return NULL;
+}
+
+struct device *
+atm_Create(struct physical *p)
+{
+ struct atmdevice *dev;
+
+ dev = NULL;
+ if (p->fd < 0 && !strncasecmp(p->name.full, PPPOA, PPPOA_LEN)
+ && p->name.full[PPPOA_LEN] == ':') {
+ char iface[25];
+ unsigned vci, vpi;
+
+ if (sscanf(p->name.full + PPPOA_LEN + 1, "%25[A-Za-z0-9]:%u.%u", iface,
+ &vpi, &vci) != 3) {
+ log_Printf(LogWARN, "Malformed ATM device name \'%s\', "
+ "PPPoA:if:vpi.vci expected\n", p->name.full);
+ return NULL;
+ }
+
+ dev = atm_CreateDevice(p, iface, vpi, vci);
+ }
+
+ if (dev) {
+ memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev);
+ physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
+ if (p->cfg.cd.necessity != CD_DEFAULT)
+ log_Printf(LogWARN, "Carrier settings ignored\n");
+ return &dev->dev;
+ }
+
+ return NULL;
+}
View
35 freebsd4/usr.sbin/ppp/atm.h
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2000 Jakob Stoklund Olesen <stoklund@taxidriver.dk>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/atm.h,v 1.1 2000/09/14 22:02:54 brian Exp $
+ */
+
+struct physical;
+struct device;
+
+extern struct device *atm_Create(struct physical *);
+extern struct device *atm_iov2device(int, struct physical *,
+ struct iovec *, int *, int, int *, int *);
+extern int atm_DeviceSize(void);
View
51 freebsd4/usr.sbin/ppp/auth.c
@@ -1,31 +1,38 @@
-/*
- * PPP Secret Key Module
+/*-
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
+ * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
+ * Internet Initiative Japan, Inc (IIJ)
+ * All rights reserved.
*
- * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Internet Initiative Japan, Inc. The name of the
- * IIJ may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.50 1999/12/27 11:43:30 brian Exp $
- *
- * TODO:
- * o Implement check against with registered IP addresses.
+ * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.52 2001/08/14 16:05:50 brian Exp $
*/
+
#include <sys/param.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <sys/socket.h>
#include <sys/un.h>
#include <pwd.h>
@@ -45,6 +52,8 @@
#include "slcompress.h"
#include "lqr.h"
#include "hdlc.h"
+#include "ncpaddr.h"
+#include "ip.h"
#include "ipcp.h"
#include "auth.h"
#include "systems.h"
@@ -64,6 +73,8 @@
#include "async.h"
#include "physical.h"
#include "datalink.h"
+#include "ipv6cp.h"
+#include "ncp.h"
#include "bundle.h"
const char *
View
42 freebsd4/usr.sbin/ppp/auth.h
@@ -1,23 +1,31 @@
-/*
- * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+/*-
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
+ * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
+ * Internet Initiative Japan, Inc (IIJ)
+ * All rights reserved.
*
- * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Internet Initiative Japan. The name of the
- * IIJ may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/ppp/auth.h,v 1.18 1999/08/28 01:18:16 peter Exp $
- *
- * TODO:
+ * $FreeBSD: src/usr.sbin/ppp/auth.h,v 1.19 2001/06/13 21:52:16 brian Exp $
*/
struct physical;
View
433 freebsd4/usr.sbin/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/ppp/bundle.c,v 1.84.2.6 2000/08/19 09:29:59 brian Exp $
+ * $FreeBSD: src/usr.sbin/ppp/bundle.c,v 1.123 2001/08/21 11:07:58 brian Exp $
*/
#include <sys/param.h>
@@ -31,7 +31,6 @@
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_tun.h> /* For TUNS* ioctls */
-#include <arpa/inet.h>
#include <net/route.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
@@ -72,6 +71,8 @@
#include "hdlc.h"
#include "throughput.h"
#include "slcompress.h"
+#include "ncpaddr.h"
+#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
@@ -83,6 +84,8 @@
#ifndef NORADIUS
#include "radius.h"
#endif
+#include "ipv6cp.h"
+#include "ncp.h"
#include "bundle.h"
#include "async.h"
#include "physical.h"
@@ -94,8 +97,12 @@
#include "chat.h"
#include "cbcp.h"
#include "datalink.h"
-#include "ip.h"
#include "iface.h"
+#include "server.h"
+#include "probe.h"
+#ifdef HAVE_DES
+#include "mppe.h"
+#endif
#define SCATTER_SEGMENTS 7 /* version, datalink, name, physical,
throughput, throughput, device */
@@ -127,8 +134,11 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
switch (new) {
case PHASE_DEAD:
- log_DisplayPrompts();
bundle->phase = new;
+#ifdef HAVE_DES
+ MPPE_MasterKeyValid = 0;
+#endif
+ log_DisplayPrompts();
break;
case PHASE_ESTABLISH:
@@ -141,10 +151,13 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
break;
case PHASE_NETWORK:
- fsm_Up(&bundle->ncp.ipcp.fsm);
- fsm_Open(&bundle->ncp.ipcp.fsm);
- bundle->phase = new;
- log_DisplayPrompts();
+ if (ncp_fsmStart(&bundle->ncp, bundle)) {
+ bundle->phase = new;
+ log_DisplayPrompts();
+ } else {
+ log_Printf(LogPHASE, "bundle: All NCPs are disabled\n");
+ bundle_Close(bundle, NULL, CLOSE_STAYDOWN);
+ }
break;
case PHASE_TERMINATE:
@@ -208,8 +221,7 @@ bundle_ClearQueues(void *v)
* dictionaries in use (causing the relevant RESET_REQ/RESET_ACK).
*/
- ip_DeleteQueue(&bundle->ncp.ipcp);
- mp_DeleteQueue(&bundle->ncp.mp);
+ ncp_DeleteQueues(&bundle->ncp);
for (dl = bundle->links; dl; dl = dl->next)
physical_DeleteQueue(dl->physical);
}
@@ -264,13 +276,16 @@ bundle_LayerUp(void *v, struct fsm *fp)
bundle_LinkAdded(bundle, p->dl);
mp_CheckAutoloadTimer(&bundle->ncp.mp);
- } else if (fp->proto == PROTO_IPCP) {
- bundle_CalculateBandwidth(fp->bundle);
- time(&bundle->upat);
- bundle_StartIdleTimer(bundle, 0);
+ } else if (isncp(fp->proto)) {
+ if (ncp_LayersOpen(&fp->bundle->ncp) == 1) {
+ bundle_CalculateBandwidth(fp->bundle);
+ time(&bundle->upat);
+ bundle_StartIdleTimer(bundle, 0);
+ mp_CheckAutoloadTimer(&fp->bundle->ncp.mp);
+ }
bundle_Notify(bundle, EX_NORMAL);
- mp_CheckAutoloadTimer(&fp->bundle->ncp.mp);
- }
+ } else if (fp->proto == PROTO_CCP)
+ bundle_CalculateBandwidth(fp->bundle); /* Against ccp_MTUOverhead */
}
static void
@@ -289,10 +304,12 @@ bundle_LayerDown(void *v, struct fsm *fp)
struct bundle *bundle = (struct bundle *)v;
- if (fp->proto == PROTO_IPCP) {
- bundle_StopIdleTimer(bundle);
- bundle->upat = 0;
- mp_StopAutoloadTimer(&bundle->ncp.mp);
+ if (isncp(fp->proto)) {
+ if (ncp_LayersOpen(&fp->bundle->ncp) == 0) {
+ bundle_StopIdleTimer(bundle);
+ bundle->upat = 0;
+ mp_StopAutoloadTimer(&bundle->ncp.mp);
+ }
} else if (fp->proto == PROTO_LCP) {
struct datalink *dl;
struct datalink *lost;
@@ -321,7 +338,7 @@ bundle_LayerDown(void *v, struct fsm *fp)
if (!others_active)
/* Down the NCPs. We don't expect to get fsm_Close()d ourself ! */
- fsm2initial(&bundle->ncp.ipcp.fsm);
+ ncp2initial(&bundle->ncp);
}
}
@@ -336,7 +353,7 @@ bundle_LayerFinish(void *v, struct fsm *fp)
struct bundle *bundle = (struct bundle *)v;
struct datalink *dl;
- if (fp->proto == PROTO_IPCP) {
+ if (isncp(fp->proto) && !ncp_LayersUnfinished(&bundle->ncp)) {
if (bundle_Phase(bundle) != PHASE_DEAD)
bundle_NewPhase(bundle, PHASE_TERMINATE);
for (dl = bundle->links; dl; dl = dl->next)
@@ -346,12 +363,6 @@ bundle_LayerFinish(void *v, struct fsm *fp)
}
}
-int
-bundle_LinkIsUp(const struct bundle *bundle)
-{
- return bundle->ncp.ipcp.fsm.state == ST_OPENED;
-}
-
void
bundle_Close(struct bundle *bundle, const char *name, int how)
{
@@ -375,7 +386,7 @@ bundle_Close(struct bundle *bundle, const char *name, int how)
switch (how) {
case CLOSE_LCP:
datalink_DontHangup(dl);
- /* fall through */
+ break;
case CLOSE_STAYDOWN:
datalink_StayDown(dl);
break;
@@ -391,11 +402,10 @@ bundle_Close(struct bundle *bundle, const char *name, int how)
if (!others_active) {
bundle_StopIdleTimer(bundle);
- if (bundle->ncp.ipcp.fsm.state > ST_CLOSED ||
- bundle->ncp.ipcp.fsm.state == ST_STARTING)
- fsm_Close(&bundle->ncp.ipcp.fsm);
+ if (ncp_LayersUnfinished(&bundle->ncp))
+ ncp_Close(&bundle->ncp);
else {
- fsm2initial(&bundle->ncp.ipcp.fsm);
+ ncp2initial(&bundle->ncp);
for (dl = bundle->links; dl; dl = dl->next)
datalink_Close(dl, how);
}
@@ -413,29 +423,6 @@ bundle_Down(struct bundle *bundle, int how)
datalink_Down(dl, how);
}
-static size_t
-bundle_FillQueues(struct bundle *bundle)
-{
- size_t total;
-
- if (bundle->ncp.mp.active)
- total = mp_FillQueues(bundle);
- else {
- struct datalink *dl;
- size_t add;
-
- for (total = 0, dl = bundle->links; dl; dl = dl->next)
- if (dl->state == DATALINK_OPEN) {
- add = link_QueueLen(&dl->physical->link);
- if (add == 0 && dl->physical->out == NULL)
- add = ip_PushPacket(&dl->physical->link, bundle);
- total += add;
- }
- }
-
- return total + ip_QueueLen(&bundle->ncp.ipcp);
-}
-
static int
bundle_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
@@ -452,7 +439,8 @@ bundle_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
nlinks++;
if (nlinks) {
- queued = r ? bundle_FillQueues(bundle) : ip_QueueLen(&bundle->ncp.ipcp);
+ queued = r ? ncp_FillPhysicalQueues(&bundle->ncp, bundle) :
+ ncp_QueueLen(&bundle->ncp);
if (r && (bundle->phase == PHASE_NETWORK ||
bundle->phys_type.all & PHYS_AUTO)) {
@@ -522,6 +510,7 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
{
struct datalink *dl;
unsigned secs;
+ u_int32_t af;
if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
descriptor_Read(&bundle->ncp.mp.server.desc, bundle, fdset);
@@ -564,16 +553,23 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
bundle->dev.Name, n);
return;
}
- if (ntohl(tun.header.family) != AF_INET)
+ af = ntohl(tun.header.family);
+#ifndef NOINET6
+ if (af != AF_INET && af != AF_INET6)
+#else
+ if (af != AF_INET)
+#endif
/* XXX: Should be maintaining drop/family counts ! */
return;
- }
+ } else
+ af = AF_INET;
- if (((struct ip *)tun.data)->ip_dst.s_addr ==
+ if (af == AF_INET && ((struct ip *)tun.data)->ip_dst.s_addr ==
bundle->ncp.ipcp.my_ip.s_addr) {
/* we've been asked to send something addressed *to* us :( */
if (Enabled(bundle, OPT_LOOPBACK)) {
- pri = PacketCheck(bundle, tun.data, n, &bundle->filter.in, NULL, NULL);
+ pri = PacketCheck(bundle, af, tun.data, n, &bundle->filter.in,
+ NULL, NULL);
if (pri >= 0) {
n += sz - sizeof tun.data;
write(bundle->dev.fd, data, n);
@@ -585,8 +581,8 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
}
/*
- * Process on-demand dialup. Output packets are queued within tunnel
- * device until IPCP is opened.
+ * Process on-demand dialup. Output packets are queued within the tunnel
+ * device until the appropriate NCP is opened.
*/
if (bundle_Phase(bundle) == PHASE_DEAD) {
@@ -594,7 +590,8 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
* Note, we must be in AUTO mode :-/ otherwise our interface should
* *not* be UP and we can't receive data
*/
- pri = PacketCheck(bundle, tun.data, n, &bundle->filter.dial, NULL, NULL);
+ pri = PacketCheck(bundle, af, tun.data, n, &bundle->filter.dial,
+ NULL, NULL);
if (pri >= 0)
bundle_Open(bundle, NULL, PHYS_AUTO, 0);
else
@@ -609,11 +606,12 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
}
secs = 0;
- pri = PacketCheck(bundle, tun.data, n, &bundle->filter.out, NULL, &secs);
+ pri = PacketCheck(bundle, af, tun.data, n, &bundle->filter.out,
+ NULL, &secs);
if (pri >= 0) {
/* Prepend the number of seconds timeout given in the filter */
tun.header.timeout = secs;
- ip_Enqueue(&bundle->ncp.ipcp, pri, (char *)&tun, n + sizeof tun.header);
+ ncp_Enqueue(&bundle->ncp, af, pri, (char *)&tun, n + sizeof tun.header);
}
}
}
@@ -640,7 +638,7 @@ void
bundle_LockTun(struct bundle *bundle)
{
FILE *lockfile;
- char pidfile[MAXPATHLEN];
+ char pidfile[PATH_MAX];
snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
lockfile = ID0fopen(pidfile, "w");
@@ -658,7 +656,7 @@ bundle_LockTun(struct bundle *bundle)
static void
bundle_UnlockTun(struct bundle *bundle)
{
- char pidfile[MAXPATHLEN];
+ char pidfile[PATH_MAX];
snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
ID0unlink(pidfile);
@@ -700,7 +698,7 @@ bundle_Create(const char *prefix, int type, int unit)
bundle.dev.fd = ID0open(bundle.dev.Name, O_RDWR);
if (bundle.dev.fd >= 0)
break;
- else if (errno == ENXIO) {
+ else if (errno == ENXIO || errno == ENOENT) {
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
if (bundle.unit == minunit && !kldtried++) {
/*
@@ -716,11 +714,10 @@ bundle_Create(const char *prefix, int type, int unit)
}
}
#endif
- err = errno;
- break;
- } else if (errno == ENOENT) {
- if (++enoentcount > 2)
+ if (errno != ENOENT || ++enoentcount > 2) {
+ err = errno;
break;
+ }
} else
err = errno;
}
@@ -749,8 +746,8 @@ bundle_Create(const char *prefix, int type, int unit)
}
#ifdef TUNSIFMODE
- /* Make sure we're POINTOPOINT */
- iff = IFF_POINTOPOINT;
+ /* Make sure we're POINTOPOINT & IFF_MULTICAST */
+ iff = IFF_POINTOPOINT | IFF_MULTICAST;
if (ID0ioctl(bundle.dev.fd, TUNSIFMODE, &iff) < 0)
log_Printf(LogERROR, "bundle_Create: ioctl(TUNSIFMODE): %s\n",
strerror(errno));
@@ -787,13 +784,6 @@ bundle_Create(const char *prefix, int type, int unit)
#endif
#endif
- if (!iface_SetFlags(bundle.iface, IFF_UP)) {
- iface_Destroy(bundle.iface);
- bundle.iface = NULL;
- close(bundle.dev.fd);
- return NULL;
- }
-
log_Printf(LogPHASE, "Using interface: %s\n", ifname);
bundle.bandwidth = 0;
@@ -812,10 +802,14 @@ bundle_Create(const char *prefix, int type, int unit)
bundle.cfg.idle.min_timeout = 0;
*bundle.cfg.auth.name = '\0';
*bundle.cfg.auth.key = '\0';
- bundle.cfg.opt = OPT_SROUTES | OPT_IDCHECK | OPT_LOOPBACK |
+ bundle.cfg.opt = OPT_IDCHECK | OPT_LOOPBACK | OPT_SROUTES | OPT_TCPMSSFIXUP |
OPT_THROUGHPUT | OPT_UTMP;
+#ifndef NOINET6
+ bundle.cfg.opt |= OPT_IPCP;
+ if (probe.ipv6_available)
+ bundle.cfg.opt |= OPT_IPV6CP;
+#endif
*bundle.cfg.label = '\0';
- bundle.cfg.mtu = DEF_MTU;
bundle.cfg.ifqueue = DEF_IFQUEUE;
bundle.cfg.choked.timeout = CHOKED_TIMEOUT;
bundle.phys_type.all = type;
@@ -837,11 +831,7 @@ bundle_Create(const char *prefix, int type, int unit)
bundle.desc.Read = bundle_DescriptorRead;
bundle.desc.Write = bundle_DescriptorWrite;
- mp_Init(&bundle.ncp.mp, &bundle);
-
- /* Send over the first physical link by default */
- ipcp_Init(&bundle.ncp.ipcp, &bundle, &bundle.links->physical->link,
- &bundle.fsm);
+ ncp_Init(&bundle.ncp, &bundle);
memset(&bundle.filter, '\0', sizeof bundle.filter);
bundle.filter.in.fragok = bundle.filter.in.logok = 1;
@@ -870,7 +860,7 @@ bundle_Create(const char *prefix, int type, int unit)
#endif
/* Clean out any leftover crud */
- iface_Clear(bundle.iface, IFACE_CLEAR_ALL);
+ iface_Clear(bundle.iface, &bundle.ncp, 0, IFACE_CLEAR_ALL);
bundle_LockTun(&bundle);
@@ -881,7 +871,7 @@ static void
bundle_DownInterface(struct bundle *bundle)
{
route_IfDelete(bundle, 1);
- iface_ClearFlags(bundle->iface, IFF_UP);
+ iface_ClearFlags(bundle->iface->name, IFF_UP);
}
void
@@ -890,14 +880,14 @@ bundle_Destroy(struct bundle *bundle)
struct datalink *dl;
/*
- * Clean up the interface. We don't need to timer_Stop()s, mp_Down(),
- * ipcp_CleanInterface() and bundle_DownInterface() unless we're getting
+ * Clean up the interface. We don't really need to do the timer_Stop()s,
+ * mp_Down(), iface_Clear() and bundle_DownInterface() unless we're getting
* out under exceptional conditions such as a descriptor exception.
*/
timer_Stop(&bundle->idle.timer);
timer_Stop(&bundle->choked.timer);
mp_Down(&bundle->ncp.mp);
- ipcp_CleanInterface(&bundle->ncp.ipcp);
+ iface_Clear(bundle->iface, &bundle->ncp, 0, IFACE_CLEAR_ALL);
bundle_DownInterface(bundle);
#ifndef NORADIUS
@@ -910,7 +900,7 @@ bundle_Destroy(struct bundle *bundle)
while (dl)
dl = datalink_Destroy(dl);
- ipcp_Destroy(&bundle->ncp.ipcp);
+ ncp_Destroy(&bundle->ncp);
close(bundle->dev.fd);
bundle_UnlockTun(bundle);
@@ -922,127 +912,6 @@ bundle_Destroy(struct bundle *bundle)
bundle->iface = NULL;
}
-struct rtmsg {
- struct rt_msghdr m_rtm;
- char m_space[64];
-};
-
-int
-bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
- struct in_addr gateway, struct in_addr mask, int bang, int ssh)
-{
- struct rtmsg rtmes;
- int s, nb, wb;
- char *cp;
- const char *cmdstr;
- struct sockaddr_in rtdata;
- int result = 1;
-
- if (bang)
- cmdstr = (cmd == RTM_ADD ? "Add!" : "Delete!");
- else
- cmdstr = (cmd == RTM_ADD ? "Add" : "Delete");
- s = ID0socket(PF_ROUTE, SOCK_RAW, 0);
- if (s < 0) {
- log_Printf(LogERROR, "bundle_SetRoute: socket(): %s\n", strerror(errno));
- return result;
- }
- memset(&rtmes, '\0', sizeof rtmes);
- rtmes.m_rtm.rtm_version = RTM_VERSION;
- rtmes.m_rtm.rtm_type = cmd;
- rtmes.m_rtm.rtm_addrs = RTA_DST;
- rtmes.m_rtm.rtm_seq = ++bundle->routing_seq;
- rtmes.m_rtm.rtm_pid = getpid();
- rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
-
- if (cmd == RTM_ADD || cmd == RTM_CHANGE) {
- if (bundle->ncp.ipcp.cfg.sendpipe > 0) {
- rtmes.m_rtm.rtm_rmx.rmx_sendpipe = bundle->ncp.ipcp.cfg.sendpipe;
- rtmes.m_rtm.rtm_inits |= RTV_SPIPE;
- }
- if (bundle->ncp.ipcp.cfg.recvpipe > 0) {
- rtmes.m_rtm.rtm_rmx.rmx_recvpipe = bundle->ncp.ipcp.cfg.recvpipe;
- rtmes.m_rtm.rtm_inits |= RTV_RPIPE;
- }
- }
-
- memset(&rtdata, '\0', sizeof rtdata);
- rtdata.sin_len = sizeof rtdata;
- rtdata.sin_family = AF_INET;
- rtdata.sin_port = 0;
- rtdata.sin_addr = dst;
-
- cp = rtmes.m_space;
- memcpy(cp, &rtdata, rtdata.sin_len);
- cp += rtdata.sin_len;
- if (cmd == RTM_ADD) {
- if (gateway.s_addr == INADDR_ANY) {
- if (!ssh)
- log_Printf(LogERROR, "bundle_SetRoute: Cannot add a route with"
- " destination 0.0.0.0\n");
- close(s);
- return result;
- } else {
- rtdata.sin_addr = gateway;
- memcpy(cp, &rtdata, rtdata.sin_len);
- cp += rtdata.sin_len;
- rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY;
- }
- }
-
- if (dst.s_addr == INADDR_ANY)
- mask.s_addr = INADDR_ANY;
-
- if (cmd == RTM_ADD || dst.s_addr == INADDR_ANY) {
- rtdata.sin_addr = mask;
- memcpy(cp, &rtdata, rtdata.sin_len);
- cp += rtdata.sin_len;
- rtmes.m_rtm.rtm_addrs |= RTA_NETMASK;
- }
-
- nb = cp - (char *) &rtmes;
- rtmes.m_rtm.rtm_msglen = nb;
- wb = ID0write(s, &rtmes, nb);
- if (wb < 0) {
- log_Printf(LogTCPIP, "bundle_SetRoute failure:\n");
- log_Printf(LogTCPIP, "bundle_SetRoute: Cmd = %s\n", cmdstr);
- log_Printf(LogTCPIP, "bundle_SetRoute: Dst = %s\n", inet_ntoa(dst));
- log_Printf(LogTCPIP, "bundle_SetRoute: Gateway = %s\n",
- inet_ntoa(gateway));
- log_Printf(LogTCPIP, "bundle_SetRoute: Mask = %s\n", inet_ntoa(mask));
-failed:
- if (cmd == RTM_ADD && (rtmes.m_rtm.rtm_errno == EEXIST ||
- (rtmes.m_rtm.rtm_errno == 0 && errno == EEXIST))) {
- if (!bang) {
- log_Printf(LogWARN, "Add route failed: %s already exists\n",
- dst.s_addr == 0 ? "default" : inet_ntoa(dst));
- result = 0; /* Don't add to our dynamic list */
- } else {
- rtmes.m_rtm.rtm_type = cmd = RTM_CHANGE;
- if ((wb = ID0write(s, &rtmes, nb)) < 0)
- goto failed;
- }
- } else if (cmd == RTM_DELETE &&
- (rtmes.m_rtm.rtm_errno == ESRCH ||
- (rtmes.m_rtm.rtm_errno == 0 && errno == ESRCH))) {
- if (!bang)
- log_Printf(LogWARN, "Del route failed: %s: Non-existent\n",
- inet_ntoa(dst));
- } else if (rtmes.m_rtm.rtm_errno == 0) {
- if (!ssh || errno != ENETUNREACH)
- log_Printf(LogWARN, "%s route failed: %s: errno: %s\n", cmdstr,
- inet_ntoa(dst), strerror(errno));
- } else
- log_Printf(LogWARN, "%s route failed: %s: %s\n",
- cmdstr, inet_ntoa(dst), strerror(rtmes.m_rtm.rtm_errno));
- }
- log_Printf(LogDEBUG, "wrote %d: cmd = %s, dst = %x, gateway = %x\n",
- wb, cmdstr, (unsigned)dst.s_addr, (unsigned)gateway.s_addr);
- close(s);
-
- return result;
-}
-
void
bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
{
@@ -1068,7 +937,7 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
if (!other_links) {
if (dl->physical->type != PHYS_AUTO) /* Not in -auto mode */
bundle_DownInterface(bundle);
- fsm2initial(&bundle->ncp.ipcp.fsm);
+ ncp2initial(&bundle->ncp);
bundle_NewPhase(bundle, PHASE_DEAD);
bundle_StopIdleTimer(bundle);
}
@@ -1171,22 +1040,34 @@ bundle_ShowStatus(struct cmdargs const *arg)
(secs / 60) % 60, secs % 60);
}
prompt_Printf(arg->prompt, "\n Queued: %lu of %u\n",
- (unsigned long)ip_QueueLen(&arg->bundle->ncp.ipcp),
+ (unsigned long)ncp_QueueLen(&arg->bundle->ncp),
arg->bundle->cfg.ifqueue);
prompt_Printf(arg->prompt, "\nDefaults:\n");
- prompt_Printf(arg->prompt, " Label: %s\n", arg->bundle->cfg.label);
- prompt_Printf(arg->prompt, " Auth name: %s\n",
+ prompt_Printf(arg->prompt, " Label: %s\n",
+ arg->bundle->cfg.label);
+ prompt_Printf(arg->prompt, " Auth name: %s\n",
arg->bundle->cfg.auth.name);
+ prompt_Printf(arg->prompt, " Diagnostic socket: ");
+ if (*server.cfg.sockname != '\0') {
+ prompt_Printf(arg->prompt, "%s", server.cfg.sockname);
+ if (server.cfg.mask != (mode_t)-1)
+ prompt_Printf(arg->prompt, ", mask 0%03o", (int)server.cfg.mask);
+ prompt_Printf(arg->prompt, "%s\n", server.fd == -1 ? " (not open)" : "");
+ } else if (server.cfg.port != 0)
+ prompt_Printf(arg->prompt, "TCP port %d%s\n", server.cfg.port,
+ server.fd == -1 ? " (not open)" : "");
+ else
+ prompt_Printf(arg->prompt, "none\n");
- prompt_Printf(arg->prompt, " Choked Timer: %ds\n",
+ prompt_Printf(arg->prompt, " Choked Timer: %ds\n",
arg->bundle->cfg.choked.timeout);
#ifndef NORADIUS
radius_Show(&arg->bundle->radius, arg->prompt);
#endif
- prompt_Printf(arg->prompt, " Idle Timer: ");
+ prompt_Printf(arg->prompt, " Idle Timer: ");
if (arg->bundle->cfg.idle.timeout) {
prompt_Printf(arg->prompt, "%ds", arg->bundle->cfg.idle.timeout);
if (arg->bundle->cfg.idle.min_timeout)
@@ -1198,45 +1079,37 @@ bundle_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "\n");
} else
prompt_Printf(arg->prompt, "disabled\n");
- prompt_Printf(arg->prompt, " MTU: ");
- if (arg->bundle->cfg.mtu)
- prompt_Printf(arg->prompt, "%d\n", arg->bundle->cfg.mtu);
- else
- prompt_Printf(arg->prompt, "unspecified\n");
- prompt_Printf(arg->prompt, " sendpipe: ");
- if (arg->bundle->ncp.ipcp.cfg.sendpipe > 0)
- prompt_Printf(arg->prompt, "%-20ld", arg->bundle->ncp.ipcp.cfg.sendpipe);
- else
- prompt_Printf(arg->prompt, "unspecified ");
- prompt_Printf(arg->prompt, " recvpipe: ");
- if (arg->bundle->ncp.ipcp.cfg.recvpipe > 0)
- prompt_Printf(arg->prompt, "%ld\n", arg->bundle->ncp.ipcp.cfg.recvpipe);
- else
- prompt_Printf(arg->prompt, "unspecified\n");
-
- prompt_Printf(arg->prompt, " Sticky Routes: %-20.20s",
- optval(arg->bundle, OPT_SROUTES));
- prompt_Printf(arg->prompt, " Filter Decap: %s\n",
+ prompt_Printf(arg->prompt, " Filter Decap: %-20.20s",
optval(arg->bundle, OPT_FILTERDECAP));
- prompt_Printf(arg->prompt, " ID check: %-20.20s",
+ prompt_Printf(arg->prompt, " ID check: %s\n",
optval(arg->bundle, OPT_IDCHECK));
- prompt_Printf(arg->prompt, " Keep-Session: %s\n",
+ prompt_Printf(arg->prompt, " Iface-Alias: %-20.20s",
+ optval(arg->bundle, OPT_IFACEALIAS));
+#ifndef NOINET6
+ prompt_Printf(arg->prompt, " IPCP: %s\n",
+ optval(arg->bundle, OPT_IPCP));
+ prompt_Printf(arg->prompt, " IPV6CP: %-20.20s",
+ optval(arg->bundle, OPT_IPV6CP));
+#endif
+ prompt_Printf(arg->prompt, " Keep-Session: %s\n",
optval(arg->bundle, OPT_KEEPSESSION));
- prompt_Printf(arg->prompt, " Loopback: %-20.20s",
+ prompt_Printf(arg->prompt, " Loopback: %-20.20s",
optval(arg->bundle, OPT_LOOPBACK));
- prompt_Printf(arg->prompt, " PasswdAuth: %s\n",
+ prompt_Printf(arg->prompt, " PasswdAuth: %s\n",
optval(arg->bundle, OPT_PASSWDAUTH));
- prompt_Printf(arg->prompt, " Proxy: %-20.20s",
+ prompt_Printf(arg->prompt, " Proxy: %-20.20s",
optval(arg->bundle, OPT_PROXY));
- prompt_Printf(arg->prompt, " Proxyall: %s\n",
+ prompt_Printf(arg->prompt, " Proxyall: %s\n",
optval(arg->bundle, OPT_PROXYALL));
- prompt_Printf(arg->prompt, " Throughput: %-20.20s",
+ prompt_Printf(arg->prompt, " Sticky Routes: %-20.20s",
+ optval(arg->bundle, OPT_SROUTES));
+ prompt_Printf(arg->prompt, " TCPMSS Fixup: %s\n",
+ optval(arg->bundle, OPT_TCPMSSFIXUP));
+ prompt_Printf(arg->prompt, " Throughput: %-20.20s",
optval(arg->bundle, OPT_THROUGHPUT));
- prompt_Printf(arg->prompt, " Utmp Logging: %s\n",
+ prompt_Printf(arg->prompt, " Utmp Logging: %s\n",
optval(arg->bundle, OPT_UTMP));
- prompt_Printf(arg->prompt, " Iface-Alias: %s\n",
- optval(arg->bundle, OPT_IFACEALIAS));
return 0;
}
@@ -1289,7 +1162,7 @@ bundle_SetIdleTimer(struct bundle *bundle, int timeout, int min_timeout)
bundle->cfg.idle.timeout = timeout;
if (min_timeout >= 0)
bundle->cfg.idle.min_timeout = min_timeout;
- if (bundle_LinkIsUp(bundle))
+ if (ncp_LayersOpen(&bundle->ncp))
bundle_StartIdleTimer(bundle, 0);
}
@@ -1901,18 +1774,20 @@ bundle_Exception(struct bundle *bundle, int fd)
}
void
-bundle_AdjustFilters(struct bundle *bundle, struct in_addr *my_ip,
- struct in_addr *peer_ip)
+bundle_AdjustFilters(struct bundle *bundle, struct ncpaddr *local,
+ struct ncpaddr *remote)
{
- filter_AdjustAddr(&bundle->filter.in, my_ip, peer_ip, NULL);
- filter_AdjustAddr(&bundle->filter.out, my_ip, peer_ip, NULL);
- filter_AdjustAddr(&bundle->filter.dial, my_ip, peer_ip, NULL);
- filter_AdjustAddr(&bundle->filter.alive, my_ip, peer_ip, NULL);
+ filter_AdjustAddr(&bundle->filter.in, local, remote, NULL);
+ filter_AdjustAddr(&bundle->filter.out, local, remote, NULL);
+ filter_AdjustAddr(&bundle->filter.dial, local, remote, NULL);
+ filter_AdjustAddr(&bundle->filter.alive, local, remote, NULL);
}
void
-bundle_AdjustDNS(struct bundle *bundle, struct in_addr dns[2])
+bundle_AdjustDNS(struct bundle *bundle)
{
+ struct in_addr *dns = bundle->ncp.ipcp.ns.dns;
+
filter_AdjustAddr(&bundle->filter.in, NULL, NULL, dns);
filter_AdjustAddr(&bundle->filter.out, NULL, NULL, dns);
filter_AdjustAddr(&bundle->filter.dial, NULL, NULL, dns);
@@ -1923,11 +1798,16 @@ void
bundle_CalculateBandwidth(struct bundle *bundle)
{
struct datalink *dl;
- int mtu, sp;
+ int sp, overhead, maxoverhead;
bundle->bandwidth = 0;
- mtu = 0;
- for (dl = bundle->links; dl; dl = dl->next)
+ bundle->iface->mtu = 0;
+ maxoverhead = 0;
+
+ for (dl = bundle->links; dl; dl = dl->next) {
+ overhead = ccp_MTUOverhead(&dl->physical->link.ccp);
+ if (maxoverhead < overhead)
+ maxoverhead = overhead;
if (dl->state == DATALINK_OPEN) {
if ((sp = dl->mp.bandwidth) == 0 &&
(sp = physical_GetSpeed(dl->physical)) == 0)
@@ -1936,28 +1816,41 @@ bundle_CalculateBandwidth(struct bundle *bundle)
else
bundle->bandwidth += sp;
if (!bundle->ncp.mp.active) {
- mtu = dl->physical->link.lcp.his_mru;
+ bundle->iface->mtu = dl->physical->link.lcp.his_mru;
break;
}
}
+ }
if(bundle->bandwidth == 0)
bundle->bandwidth = 115200; /* Shrug */
- if (bundle->ncp.mp.active)
- mtu = bundle->ncp.mp.peer_mrru;
- else if (!mtu)
- mtu = 1500;
+ if (bundle->ncp.mp.active) {
+ bundle->iface->mtu = bundle->ncp.mp.peer_mrru;
+ overhead = ccp_MTUOverhead(&bundle->ncp.mp.link.ccp);
+ if (maxoverhead < overhead)
+ maxoverhead = overhead;
+ } else if (!bundle->iface->mtu)
+ bundle->iface->mtu = DEF_MRU;
#ifndef NORADIUS
- if (bundle->radius.valid && bundle->radius.mtu && bundle->radius.mtu < mtu) {
+ if (bundle->radius.valid && bundle->radius.mtu &&
+ bundle->radius.mtu < bundle->iface->mtu) {
log_Printf(LogLCP, "Reducing MTU to radius value %lu\n",
bundle->radius.mtu);
- mtu = bundle->radius.mtu;
+ bundle->iface->mtu = bundle->radius.mtu;
}
#endif
- tun_configure(bundle, mtu);
+ if (maxoverhead) {
+ log_Printf(LogLCP, "Reducing MTU from %d to %d (CCP requirement)\n",
+ bundle->iface->mtu, bundle->iface->mtu - maxoverhead);
+ bundle->iface->mtu -= maxoverhead;
+ }
+
+ tun_configure(bundle);
+
+ route_UpdateMTU(bundle);
}
void
View
39 freebsd4/usr.sbin/ppp/bundle.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/ppp/bundle.h,v 1.33.2.4 2000/08/19 09:29:59 brian Exp $
+ * $FreeBSD: src/usr.sbin/ppp/bundle.h,v 1.46 2001/08/14 16:05:50 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@@ -36,14 +36,19 @@
#define OPT_FILTERDECAP 0x0001
#define OPT_IDCHECK 0x0002
#define OPT_IFACEALIAS 0x0004
-#define OPT_KEEPSESSION 0x0008
-#define OPT_LOOPBACK 0x0010
-#define OPT_PASSWDAUTH 0x0020
-#define OPT_PROXY 0x0040
-#define OPT_PROXYALL 0x0080
-#define OPT_SROUTES 0x0100
-#define OPT_THROUGHPUT 0x0200
-#define OPT_UTMP 0x0400
+#ifndef NOINET6
+#define OPT_IPCP 0x0008
+#define OPT_IPV6CP 0x0010
+#endif
+#define OPT_KEEPSESSION 0x0020
+#define OPT_LOOPBACK 0x0040
+#define OPT_PASSWDAUTH 0x0080
+#define OPT_PROXY 0x0100
+#define OPT_PROXYALL 0x0200
+#define OPT_SROUTES 0x0400
+#define OPT_TCPMSSFIXUP 0x0800
+#define OPT_THROUGHPUT 0x1000
+#define OPT_UTMP 0x2000
#define MAX_ENDDISC_CLASS 5
@@ -101,7 +106,6 @@ struct bundle {
} auth;
unsigned opt; /* Uses OPT_ bits from above */
char label[50]; /* last thing `load'ed */
- u_short mtu; /* Interface mtu */
u_short ifqueue; /* Interface queue size */
struct {
@@ -109,10 +113,7 @@ struct bundle {
} choked;
} cfg;
- struct {
- struct ipcp ipcp; /* Our IPCP FSM */
- struct mp mp; /* Our MP */
- } ncp;
+ struct ncp ncp;
struct {
struct filter in; /* incoming packet filter */
@@ -136,6 +137,7 @@ struct bundle {
#ifndef NORADIUS
struct radius radius; /* Info retrieved from radius server */
+ struct radacct radacct;
#endif
};
@@ -148,9 +150,6 @@ extern const char *bundle_PhaseName(struct bundle *);
#define bundle_Phase(b) ((b)->phase)
extern void bundle_NewPhase(struct bundle *, u_int);
extern void bundle_LinksRemoved(struct bundle *);
-extern int bundle_LinkIsUp(const struct bundle *);
-extern int bundle_SetRoute(struct bundle *, int, struct in_addr,
- struct in_addr, struct in_addr, int, int);
extern void bundle_Close(struct bundle *, const char *, int);
extern void bundle_Down(struct bundle *, int);
extern void bundle_Open(struct bundle *, const char *, int, int);
@@ -185,9 +184,9 @@ extern void bundle_setsid(struct bundle *, int);
extern void bundle_LockTun(struct bundle *);
extern int bundle_HighestState(struct bundle *);
extern int bundle_Exception(struct bundle *, int);
-extern void bundle_AdjustFilters(struct bundle *, struct in_addr *,
- struct in_addr *);
-extern void bundle_AdjustDNS(struct bundle *, struct in_addr [2]);
+extern void bundle_AdjustFilters(struct bundle *, struct ncpaddr *,
+ struct ncpaddr *);
+extern void bundle_AdjustDNS(struct bundle *);
extern void bundle_CalculateBandwidth(struct bundle *);
extern void bundle_AutoAdjust(struct bundle *, int, int);
extern int bundle_WantAutoloadTimer(struct bundle *);
View
2  freebsd4/usr.sbin/ppp/cbcp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/ppp/cbcp.c,v 1.18.2.2 2000/08/19 09:29:59 brian Exp $
+ * $FreeBSD: src/usr.sbin/ppp/cbcp.c,v 1.20 2000/07/19 02:10:30 brian Exp $
*/
#include <sys/param.h>
View
264 freebsd4/usr.sbin/ppp/ccp.c
@@ -1,31 +1,38 @@
-/*
- * PPP Compression Control Protocol (CCP) Module
- *
- * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
- *
- * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
+/*-
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
+ * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
+ * Internet Initiative Japan, Inc (IIJ)
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Internet Initiative Japan, Inc. The name of the
- * IIJ may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright