Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

IPv6 supported ppp from freebsd-current.

  • Loading branch information...
commit c5bbdc6be248a5ac1ba7f701fdb92ca2b4b95be9 1 parent 24a41b7
authored September 03, 2001

Showing 108 changed files with 15,553 additions and 3,288 deletions. Show diff stats Hide diff stats

  1. 42  freebsd4/usr.sbin/ppp/Makefile
  2. 34  freebsd4/usr.sbin/ppp/README.changes
  3. 28  freebsd4/usr.sbin/ppp/README.devel
  4. 378  freebsd4/usr.sbin/ppp/README.nat
  5. 2  freebsd4/usr.sbin/ppp/acf.c
  6. 28  freebsd4/usr.sbin/ppp/arp.c
  7. 45  freebsd4/usr.sbin/ppp/arp.h
  8. 44  freebsd4/usr.sbin/ppp/async.c
  9. 235  freebsd4/usr.sbin/ppp/atm.c
  10. 35  freebsd4/usr.sbin/ppp/atm.h
  11. 51  freebsd4/usr.sbin/ppp/auth.c
  12. 42  freebsd4/usr.sbin/ppp/auth.h
  13. 433  freebsd4/usr.sbin/ppp/bundle.c
  14. 39  freebsd4/usr.sbin/ppp/bundle.h
  15. 2  freebsd4/usr.sbin/ppp/cbcp.c
  16. 264  freebsd4/usr.sbin/ppp/ccp.c
  17. 78  freebsd4/usr.sbin/ppp/ccp.h
  18. 237  freebsd4/usr.sbin/ppp/chap.c
  19. 46  freebsd4/usr.sbin/ppp/chap.h
  20. 331  freebsd4/usr.sbin/ppp/chap_ms.c
  21. 59  freebsd4/usr.sbin/ppp/chap_ms.h
  22. 7  freebsd4/usr.sbin/ppp/chat.c
  23. 2  freebsd4/usr.sbin/ppp/chat.h
  24. 734  freebsd4/usr.sbin/ppp/command.c
  25. 42  freebsd4/usr.sbin/ppp/command.h
  26. 59  freebsd4/usr.sbin/ppp/datalink.c
  27. 2  freebsd4/usr.sbin/ppp/datalink.h
  28. 16  freebsd4/usr.sbin/ppp/deflate.c
  29. 9  freebsd4/usr.sbin/ppp/defs.c
  30. 51  freebsd4/usr.sbin/ppp/defs.h
  31. 2  freebsd4/usr.sbin/ppp/descriptor.h
  32. 106  freebsd4/usr.sbin/ppp/ether.c
  33. 3  freebsd4/usr.sbin/ppp/exec.c
  34. 492  freebsd4/usr.sbin/ppp/filter.c
  35. 86  freebsd4/usr.sbin/ppp/filter.h
  36. 90  freebsd4/usr.sbin/ppp/fsm.c
  37. 46  freebsd4/usr.sbin/ppp/fsm.h
  38. 47  freebsd4/usr.sbin/ppp/hdlc.c
  39. 42  freebsd4/usr.sbin/ppp/hdlc.h
  40. 3  freebsd4/usr.sbin/ppp/i4b.c
  41. 2  freebsd4/usr.sbin/ppp/id.c
  42. 2  freebsd4/usr.sbin/ppp/id.h
  43. 608  freebsd4/usr.sbin/ppp/iface.c
  44. 30  freebsd4/usr.sbin/ppp/iface.h
  45. 663  freebsd4/usr.sbin/ppp/ip.c
  46. 57  freebsd4/usr.sbin/ppp/ip.h
  47. 793  freebsd4/usr.sbin/ppp/ipcp.c
  48. 104  freebsd4/usr.sbin/ppp/ipcp.h
  49. 618  freebsd4/usr.sbin/ppp/ipv6cp.c
  50. 81  freebsd4/usr.sbin/ppp/ipv6cp.h
  51. 193  freebsd4/usr.sbin/ppp/lcp.c
  52. 46  freebsd4/usr.sbin/ppp/lcp.h
  53. 15  freebsd4/usr.sbin/ppp/link.c
  54. 2  freebsd4/usr.sbin/ppp/link.h
  55. 32  freebsd4/usr.sbin/ppp/log.c
  56. 29  freebsd4/usr.sbin/ppp/log.h
  57. 48  freebsd4/usr.sbin/ppp/lqr.c
  58. 42  freebsd4/usr.sbin/ppp/lqr.h
  59. 97  freebsd4/usr.sbin/ppp/main.c
  60. 43  freebsd4/usr.sbin/ppp/main.h
  61. 78  freebsd4/usr.sbin/ppp/mbuf.c
  62. 122  freebsd4/usr.sbin/ppp/mbuf.h
  63. 153  freebsd4/usr.sbin/ppp/mp.c
  64. 7  freebsd4/usr.sbin/ppp/mp.h
  65. 737  freebsd4/usr.sbin/ppp/mppe.c
  66. 33  freebsd4/usr.sbin/ppp/mppe.h
  67. 139  freebsd4/usr.sbin/ppp/nat_cmd.c
  68. 32  freebsd4/usr.sbin/ppp/nat_cmd.h
  69. 550  freebsd4/usr.sbin/ppp/ncp.c
  70. 101  freebsd4/usr.sbin/ppp/ncp.h
  71. 972  freebsd4/usr.sbin/ppp/ncpaddr.c
  72. 108  freebsd4/usr.sbin/ppp/ncpaddr.h
  73. 53  freebsd4/usr.sbin/ppp/pap.c
  74. 42  freebsd4/usr.sbin/ppp/pap.h
  75. 45  freebsd4/usr.sbin/ppp/physical.c
  76. 5  freebsd4/usr.sbin/ppp/physical.h
  77. 5,780  freebsd4/usr.sbin/ppp/ppp.8.m4
  78. 17  freebsd4/usr.sbin/ppp/pred.c
  79. 42  freebsd4/usr.sbin/ppp/pred.h
  80. 33  freebsd4/usr.sbin/ppp/probe.c
  81. 9  freebsd4/usr.sbin/ppp/probe.h
  82. 13  freebsd4/usr.sbin/ppp/prompt.c
  83. 7  freebsd4/usr.sbin/ppp/prompt.h
  84. 2  freebsd4/usr.sbin/ppp/proto.c
  85. 46  freebsd4/usr.sbin/ppp/proto.h
  86. 255  freebsd4/usr.sbin/ppp/radius.c
  87. 26  freebsd4/usr.sbin/ppp/radius.h
  88. 599  freebsd4/usr.sbin/ppp/route.c
  89. 78  freebsd4/usr.sbin/ppp/route.h
  90. 245  freebsd4/usr.sbin/ppp/server.c
  91. 26  freebsd4/usr.sbin/ppp/server.h
  92. 32  freebsd4/usr.sbin/ppp/sig.c
  93. 7  freebsd4/usr.sbin/ppp/slcompress.c
  94. 2  freebsd4/usr.sbin/ppp/slcompress.h
  95. 53  freebsd4/usr.sbin/ppp/systems.c
  96. 43  freebsd4/usr.sbin/ppp/systems.h
  97. 62  freebsd4/usr.sbin/ppp/tcp.c
  98. 186  freebsd4/usr.sbin/ppp/tcpmss.c
  99. 29  freebsd4/usr.sbin/ppp/tcpmss.h
  100. 2  freebsd4/usr.sbin/ppp/throughput.c
  101. 2  freebsd4/usr.sbin/ppp/throughput.h
  102. 44  freebsd4/usr.sbin/ppp/timer.c
  103. 42  freebsd4/usr.sbin/ppp/timer.h
  104. 26  freebsd4/usr.sbin/ppp/tty.c
  105. 24  freebsd4/usr.sbin/ppp/tun.c
  106. 4  freebsd4/usr.sbin/ppp/tun.h
  107. 81  freebsd4/usr.sbin/ppp/udp.c
  108. 50  freebsd4/usr.sbin/ppp/vjcomp.c
42  freebsd4/usr.sbin/ppp/Makefile
... ...
@@ -1,15 +1,13 @@
1  
-# $FreeBSD: src/usr.sbin/ppp/Makefile,v 1.73.2.2 2000/08/19 09:29:59 brian Exp $
  1
+# $FreeBSD: src/usr.sbin/ppp/Makefile,v 1.91 2001/08/14 16:05:50 brian Exp $
2 2
 
3 3
 PROG=	ppp
  4
+MAN=	ppp.8
4 5
 SRCS=	acf.c arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c \
5 6
 	command.c datalink.c deflate.c defs.c exec.c filter.c fsm.c hdlc.c \
6  
-	iface.c ip.c ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c \
7  
-	mbuf.c mp.c pap.c physical.c pred.c probe.c prompt.c proto.c route.c \
8  
-	server.c sig.c slcompress.c sync.c systems.c tcp.c throughput.c \
9  
-	timer.c tty.c tun.c udp.c vjcomp.c
10  
-CFLAGS+=-Wall
11  
-LDADD+= -lcrypt -lmd -lutil -lz
12  
-DPADD+=	${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
  7
+	iface.c ip.c ipcp.c ipv6cp.c iplist.c lcp.c link.c log.c lqr.c main.c \
  8
+	mbuf.c mp.c ncp.c ncpaddr.c pap.c physical.c pred.c probe.c prompt.c \
  9
+	proto.c route.c server.c sig.c slcompress.c sync.c systems.c tcp.c \
  10
+	tcpmss.c throughput.c timer.c tty.c tun.c udp.c vjcomp.c
13 11
 .if defined(NOSUID) || defined(PPP_NOSUID)
14 12
 BINMODE=554
15 13
 .else
@@ -17,12 +15,24 @@ BINMODE=4554
17 15
 BINOWN=	root
18 16
 .endif
19 17
 BINGRP=	network
20  
-MAN8=	ppp.8
  18
+M4FLAGS=
  19
+
  20
+LDADD= -lcrypt -lmd -lutil -lz
  21
+DPADD=	${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
  22
+
  23
+.SUFFIXES: .8 .8.m4
  24
+
  25
+.8.m4.8:
  26
+	m4 ${M4FLAGS} ${.IMPSRC} >${.TARGET}
21 27
 
22 28
 .if defined(RELEASE_CRUNCH)
23 29
 CFLAGS+=-DRELEASE_CRUNCH
24 30
 .endif
25 31
 
  32
+.if defined(PPP_CONFDIR) && !empty(PPP_CONFDIR)
  33
+CFLAGS+=-DPPP_CONFDIR=\"${PPP_CONFDIR}\"
  34
+.endif
  35
+
26 36
 .if defined(NOKLDLOAD)
27 37
 CFLAGS+=-DNOKLDLOAD
28 38
 .endif
@@ -41,6 +51,12 @@ DPADD+= ${LIBALIAS}
41 51
 .endif
42 52
 .endif
43 53
 
  54
+.if defined(NOATM) || defined(RELEASE_CRUNCH)
  55
+CFLAGS+=-DNOATM
  56
+.else
  57
+SRCS+=	atm.c
  58
+.endif
  59
+
44 60
 .if defined(NOSUID) || defined(PPP_NOSUID)
45 61
 CFLAGS+=-DNOSUID
46 62
 .else
@@ -52,7 +68,7 @@ SRCS+=	id.c
52 68
 .if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE) && !defined(NO_OPENSSL) && !defined(RELEASE_CRUNCH)
53 69
 DISTRIBUTION=crypto
54 70
 CFLAGS+=-DHAVE_DES
55  
-SRCS+=	chap_ms.c
  71
+SRCS+=	chap_ms.c mppe.c
56 72
 LDADD+= -lcrypto
57 73
 DPADD+= ${LIBCRYPTO}
58 74
 .endif
@@ -82,13 +98,7 @@ DPADD+= ${LIBNETGRAPH}
82 98
 .endif
83 99
 
84 100
 .if defined(RELEASE_CRUNCH)
85  
-# We must create these objects because crunchgen will link them,
86  
-# and we don't want any unused symbols to spoil the final link.
87 101
 CFLAGS+=-DNONAT -DNORADIUS -DNOI4B -DNOSUID
88  
-OBJS+=	chap_ms.o id.o nat_cmd.o radius.o
89  
-chap_ms.o id.o nat_cmd.o radius.o:
90  
-	>null_${.PREFIX}.c
91  
-	cc -c -o ${.TARGET} null_${.PREFIX}.c
92 102
 .endif
93 103
 
94 104
 .include <bsd.prog.mk>
34  freebsd4/usr.sbin/ppp/README.changes
... ...
@@ -1,4 +1,29 @@
1  
-$FreeBSD: src/usr.sbin/ppp/README.changes,v 1.16.2.3 2000/08/19 09:29:59 brian Exp $
  1
+Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
  2
+              based on work by Eivind Eklund <perhaps@yes.no>,
  3
+All rights reserved.
  4
+
  5
+Redistribution and use in source and binary forms, with or without
  6
+modification, are permitted provided that the following conditions
  7
+are met:
  8
+1. Redistributions of source code must retain the above copyright
  9
+   notice, this list of conditions and the following disclaimer.
  10
+2. Redistributions in binary form must reproduce the above copyright
  11
+   notice, this list of conditions and the following disclaimer in the
  12
+   documentation and/or other materials provided with the distribution.
  13
+
  14
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24
+SUCH DAMAGE.
  25
+
  26
+$FreeBSD: src/usr.sbin/ppp/README.changes,v 1.23 2001/06/04 14:38:28 brian Exp $
2 27
 
3 28
 This file summarises changes made to ppp that effect
4 29
 its configuration.
@@ -106,3 +131,10 @@ o The ``!'' at the start of chat scripts and authkey can be made literal
106 131
   (rather than meaning execute) by doubling it to ``!!''.
107 132
 o MP autoload throughput measurements are now based on the maximum of input
108 133
   and output averages rather than on the total.
  134
+o When only one link is open in MP mode, MP link level compression is not
  135
+  open and the peer MRU >= the peer MRRU, ppp sends outbound traffic as
  136
+  PROTO_IP traffic rather than PROTO_MP.
  137
+o MSCHAPv2 is now accepted by default.  If you don't wish to negotiate
  138
+  this, you must explicitly deny it.
  139
+o MPPE is enabled and accepted by default (although deflate and predictor1
  140
+  are preferred.
28  freebsd4/usr.sbin/ppp/README.devel
... ...
@@ -1,3 +1,31 @@
  1
+Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
  2
+              based on work by Eivind Eklund <perhaps@yes.no>,
  3
+All rights reserved.
  4
+
  5
+Redistribution and use in source and binary forms, with or without
  6
+modification, are permitted provided that the following conditions
  7
+are met:
  8
+1. Redistributions of source code must retain the above copyright
  9
+   notice, this list of conditions and the following disclaimer.
  10
+2. Redistributions in binary form must reproduce the above copyright
  11
+   notice, this list of conditions and the following disclaimer in the
  12
+   documentation and/or other materials provided with the distribution.
  13
+
  14
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24
+SUCH DAMAGE.
  25
+
  26
+$FreeBSD: src/usr.sbin/ppp/README.devel,v 1.5 2001/06/04 14:38:28 brian Exp $
  27
+
  28
+This file summarises changes made to ppp that effect
1 29
 This program was originally written by Toshiharu OHNO <tony-o@iij.ad.jp>,
2 30
 and was submitted to FreeBSD-2.0.5 by Atsushi Murai <amurai@spec.co.jp>.
3 31
 The original version was usually referred to as iij-ppp.
378  freebsd4/usr.sbin/ppp/README.nat
... ...
@@ -0,0 +1,378 @@
  1
+Copyright (c) 2001 Charles Mott <cmott@scientech.com>
  2
+All rights reserved.
  3
+
  4
+Redistribution and use in source and binary forms, with or without
  5
+modification, are permitted provided that the following conditions
  6
+are met:
  7
+1. Redistributions of source code must retain the above copyright
  8
+   notice, this list of conditions and the following disclaimer.
  9
+2. Redistributions in binary form must reproduce the above copyright
  10
+   notice, this list of conditions and the following disclaimer in the
  11
+   documentation and/or other materials provided with the distribution.
  12
+
  13
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23
+SUCH DAMAGE.
  24
+
  25
+$FreeBSD: src/usr.sbin/ppp/README.nat,v 1.4 2001/06/04 14:38:28 brian Exp $
  26
+
  27
+User PPP NAT (Packet Aliasing)
  28
+
  29
+
  30
+
  31
+0. Contents
  32
+    1. Background
  33
+    2. Setup
  34
+    3. New commands in ppp
  35
+    4. Future Work
  36
+    5. Authors / Acknowledgements
  37
+    6. Revision History for Aliasing Code
  38
+
  39
+
  40
+
  41
+1. Background
  42
+
  43
+User mode ppp has embedded NAT (Network Address Translation) code.
  44
+Enabling this, either by the "-nat" command line option or the
  45
+"nat enable yes" command in a ppp.conf file, makes the ppp host
  46
+automatically NAT IP packets forwarded from a local network, making
  47
+them appear to come from the ppp host machine.  Incoming packets
  48
+from the outside world are then appropriately de-NAT'd.
  49
+
  50
+The process of NAT'ing involves both the IP address and the TCP or UDP
  51
+port numbers. ICMP echo and timestamp packets are natted by their id
  52
+numbers.  ICMP error messages can be properly directed by examining the
  53
+fragment of the offending packet which is contained in the body of the
  54
+message.
  55
+
  56
+This software was specifically meant to support users who have
  57
+unregistered, private address IP networks (e.g. 192.168.0.x or 10.0.0.x
  58
+addresses).  The ppp host can act as a gateway for these networks, and
  59
+computers on the local area net will have some degree of Internet access
  60
+without the need for a registered IP address.  Additionally, there will
  61
+be no need for an Internet service provider to maintain routing tables
  62
+for the local area network.
  63
+
  64
+A disadvantage of NAT is that machines on the local network,
  65
+behind the ppp host, are not visible from the outside world.  They can
  66
+establish TCP connections and make UDP inquiries (such as domain name
  67
+service requests) but the connections seem to come from the ppp host
  68
+itself.  There is, in effect, a partial firewall.  Of course, if this is
  69
+what you want, the disadvantage becomes an advantage.
  70
+
  71
+A second disadvantage is that "IP encoding" protocols, which send IP
  72
+address or port information within the data stream, are not supported
  73
+for the cases where exception code exists.  This implementation has
  74
+workarounds for FTP and IRC DCC, the most well known of the IP encoding
  75
+protocols.  This frees users from depending on using the ftp passive
  76
+mode and avoiding IRC DCC sends, as is sometimes the case with other
  77
+masquerading solutions.
  78
+
  79
+The implementation supports all standard, non-encoding TCP and UDP protocols.
  80
+Examples of these protocols are http, gopher and telnet. The standard UDP
  81
+mode of Real-Audio is not presently supported, but the TCP mode does work
  82
+correctly.
  83
+
  84
+The NAT code also handles many ICMP messages.  In particular,
  85
+ping and traceroute are supported.
  86
+
  87
+
  88
+
  89
+2. Packet Aliasing Setup
  90
+
  91
+It is recommended that users first verify correct ppp operation without
  92
+NAT enabled.  This will confirm that the ppp.conf file is
  93
+properly set up and that there are no ppp problems. Then start ppp with
  94
+the "-nat" option on the command line.  The user should verify that
  95
+the ppp host can correctly connect to the Internet in NAT
  96
+mode.  Finally, check that machines on the private network can access
  97
+the Internet.
  98
+
  99
+The NAT software handles all packets, whether they come from
  100
+the host or another computer on the local area network.  Thus, a correctly
  101
+operating ppp host indicates that the software should work properly for
  102
+other computers on the private network.
  103
+
  104
+If the ppp host can access the Internet, but other computers on the local
  105
+network cannot, check that IP forwarding is enabled on the ppp host. Also,
  106
+verify that the other computers use this machine as a gateway.  Of course,
  107
+you should also verify that machines within the local area network
  108
+communicate properly.  A common error is inconsistent subnet addresses
  109
+and masks.
  110
+
  111
+
  112
+
  113
+3. New commands in ppp
  114
+
  115
+In order to control NAT behaviour in a simple manner (no need for
  116
+recompilation), a new command has been added to ppp: nat.  This
  117
+is in addition to the -nat command line option.  System managers and
  118
+more experienced users may prefer to use the ppp command syntax
  119
+within the ppp.conf file.  The nat command also allows NAT
  120
+behaviour to be more precisely specified.
  121
+
  122
+The decision to add a command instead of extending 'set' or 'option' was
  123
+to make obvious that these options only work when NAT is enabled.
  124
+
  125
+The syntax for 'nat' is
  126
+
  127
+    ppp>  nat option [yes|no]
  128
+
  129
+where option is given by one of the following templates.
  130
+
  131
+
  132
+ - nat enable [yes|no]  (default no)
  133
+
  134
+Enable NAT functionality.  If disabled, no other NAT
  135
+options will have any effect.  You should usually enable NAT
  136
+before routing any packets over the link; good points are in the
  137
+initial script or right before adding a route.  If you do not always
  138
+want NAT, consider using the -nat option to ppp instead of this
  139
+command.
  140
+
  141
+
  142
+ - nat deny_incoming [yes|no] (default yes)
  143
+
  144
+Set to "yes" to disable all incoming connections.  This just drops
  145
+connections to, for example, ftp, telnet or web servers.  The NAT
  146
+mechanism prevents these connections. Technically, this option denies
  147
+all incoming TCP and UDP requests, making the NAT software a
  148
+fairly efficient one-way firewall.  The default is no, which will allow
  149
+all incoming connections to telnetd, ftpd, etc.
  150
+
  151
+
  152
+ - nat log [yes|no]
  153
+
  154
+Controls logging of NAT link creation to "/var/log/alias.log" - this
  155
+is usually only useful if debugging a setup, to see if the bug is in
  156
+the PPP NATing.  The debugging information is fairly limited, listing
  157
+the number of NAT links open for different protocols.
  158
+
  159
+
  160
+ - nat same_ports [yes|no] (default yes)
  161
+
  162
+When a connection is being established going through the NAT
  163
+routines, it will normally have its port number changed to allow the
  164
+NAT code to track it.  If same_ports is enabled, the NAT
  165
+software attempts to keep the connection's source port unchanged.
  166
+This will allow rsh, RPC and other specialised protocols to work
  167
+_most of the time_, at least on the host machine.  Please, do not
  168
+report this being unstable as a bug - it is a result of the way
  169
+NAT has to work. TCP/IP was intended to have one IP address
  170
+per machine.
  171
+
  172
+
  173
+ - nat use_sockets [yes|no] (default yes)
  174
+
  175
+This is a fairly obscure option.  For the most part, the NAT
  176
+software does not have to allocate system sockets when it chooses a
  177
+NAT port number.  Under very specific circumstances, FTP data
  178
+connections (which don't know the remote port number, though it is
  179
+usually 20) and IRC DCC send (which doesn't know either the address or
  180
+the port from which the connection will come), there can potentially be
  181
+some interference with an open server socket having the same port number
  182
+on the ppp host machine.  This possibility for interference only exists
  183
+until the TCP connection has been acknowledged on both sides.  The safe
  184
+option is yes, though fewer system resources are consumed by specifying
  185
+no.
  186
+
  187
+
  188
+ - nat unregistered_only [yes|no] (default no)
  189
+
  190
+NAT normally remaps all packets coming from the local area
  191
+network to the ppp host machine address.  Set this option to only map
  192
+addresses from the following standard ranges for private, unregistered
  193
+addresses:
  194
+
  195
+                10.0.0.0     ->   10.255.255.255
  196
+                172.16.0.0   ->   172.31.255.255
  197
+                192.168.0.0  ->   192.168.255.255  */
  198
+
  199
+In the instance that there is a subnet of public addresses and another
  200
+subnet of private addresses being routed by the ppp host, then only the
  201
+packets on the private subnet will be NAT'd.
  202
+
  203
+
  204
+- nat port <proto> <local addr>:<port>  <nat port>
  205
+
  206
+This command allows incoming traffic to <nat port> on the host 
  207
+machine to be redirected to a specific machine and port on the
  208
+local area network.  One example of this would be:
  209
+
  210
+    nat port tcp 192.168.0.4:telnet  8066
  211
+
  212
+All traffic to port 8066 of the ppp host would then be sent to
  213
+the telnet port (23) of machine 192.168.0.4.  Port numbers
  214
+can either be designated numerically or by symbolic names
  215
+listed in /etc/services.  Similarly, addresses can be either
  216
+in dotted quad notation or in /etc/hosts.
  217
+
  218
+
  219
+- nat addr <local addr> <public addr>
  220
+
  221
+This command allows traffic for a public IP address to be
  222
+redirected to a machine on the local network.  This function
  223
+is known as "static NAT".  An address assignment of 0 refers
  224
+to the default address of the ppp host.  Normally static
  225
+NAT is useful if your ISP has allocated a small block of
  226
+IP addresses to the user, but it can even be used in the
  227
+case of a single, dynamically allocated IP address:
  228
+
  229
+    nat addr 10.0.0.8 0
  230
+
  231
+The above command would redirect all incoming traffic to
  232
+machine 10.0.0.8. 
  233
+
  234
+If several address NATs specify the same public address
  235
+as follows
  236
+
  237
+    nat addr 192.168.0.2  public_addr
  238
+    nat addr 192.168.0.3  public_addr
  239
+    nat addr 192.168.0.4  public_addr
  240
+
  241
+then incoming traffic will be directed to the last
  242
+translated local address (192.168.0.4), but outgoing
  243
+traffic to the first two addresses will still be NAT'd
  244
+to the specified public address.
  245
+
  246
+
  247
+
  248
+4. Future Work
  249
+
  250
+What is called NAT here has been variously called masquerading, packet
  251
+aliasing and transparent proxying by others.  It is an extremely useful
  252
+function to many users, but it is also necessarily imperfect.  The
  253
+occasional IP-encoding protocols always need workarounds (hacks).
  254
+Users who are interested in supporting new IP-encoding protocols
  255
+can follow the examples of alias_ftp.c and alias_irc.c.
  256
+
  257
+ICMP error messages are currently handled only in the incoming direction.
  258
+A handler needs to be added to correctly NAT outgoing error messages.
  259
+
  260
+IRC and FTP exception handling make reasonable, though not strictly correct
  261
+assumptions, about how IP encoded messages will appear in the control
  262
+stream.  Programmers may wish to consider how to make this process more
  263
+robust.
  264
+
  265
+The NAT engine (alias.c, alias_db.c, alias_ftp.c, alias_irc.c
  266
+and alias_util.c) runs in user space, and is intended to be both portable
  267
+and reusable for interfaces other than ppp.  To access the basic engine
  268
+only requires four simple function calls (initialisation, communication of
  269
+host address, outgoing NAT and incoming de-NATing).
  270
+
  271
+
  272
+
  273
+5. Authors / Acknowledgements
  274
+
  275
+Charles Mott (cmott@srv.net)   <versions 1.0 - 1.8, 2.0, 2.1>
  276
+Eivind Eklund (perhaps@yes.no) <versions 1.8b - 1.9, new ppp commands>
  277
+
  278
+Listed below, in chronological order, are individuals who have provided
  279
+valuable comments and/or debugging assistance.
  280
+
  281
+    Gary Roberts
  282
+    Tom Torrance
  283
+    Reto Burkhalter
  284
+    Martin Renters
  285
+    Brian Somers
  286
+    Paul Traina
  287
+    Ari Suutari
  288
+    J. Fortes
  289
+    Andrzej Bialeki
  290
+
  291
+
  292
+
  293
+6. Revision History for Aliasing Code
  294
+
  295
+Version 1.0: August 11, 1996 (cjm)
  296
+
  297
+Version 1.1:  August 20, 1996  (cjm)
  298
+    PPP host accepts incoming connections for ports 0 to 1023.
  299
+
  300
+Version 1.2:  September 7, 1996 (cjm)
  301
+    Fragment handling error in alias_db.c corrected.
  302
+
  303
+Version 1.3: September 15, 1996 (cjm)
  304
+    - Generalised mechanism for handling incoming connections
  305
+      (no more 0 to 1023 restriction).
  306
+    - Increased ICMP support (will handle traceroute now).
  307
+    - Improved TCP close connection logic.
  308
+
  309
+Version 1.4: September 16, 1996
  310
+    Can't remember (this version only lasted a day -- cjm).
  311
+
  312
+Version 1.5: September 17, 1996 (cjm)
  313
+    Corrected error in handling incoming UDP packets
  314
+    with zero checksum.
  315
+
  316
+Version 1.6: September 18, 1996
  317
+    Simplified ICMP data storage.  Will now handle
  318
+    tracert from Win95 as well as FreeBSD traceroute.
  319
+
  320
+Version 1.7: January 9, 1997 (cjm)
  321
+    - Reduced malloc() activity for ICMP echo and 
  322
+      timestamp requests.
  323
+    - Added handling for out-of-order IP fragments.
  324
+    - Switched to differential checksum computation
  325
+      for IP headers (TCP, UDP and ICMP checksums
  326
+      were already differential).
  327
+    - Accepts FTP data connections from other than
  328
+      port 20.  This allows one ftp connections
  329
+      from two hosts which are both running packet
  330
+      aliasing.
  331
+
  332
+Version 1.8: January 14, 1997 (cjm)
  333
+    - Fixed data type error in function StartPoint()
  334
+      in alias_db.c (this bug did not exist before v1.7)
  335
+
  336
+Version 1.8b: January 16, 1997 (Eivind Eklund <perhaps@yes.no>)
  337
+    - Upgraded base PPP version to be the source code from
  338
+      FreeBSD 2.1.6, with additional security patches.  This
  339
+      version should still be possible to run on 2.1.5, though -
  340
+      I've run it with a 2.1.5 kernel without problems.
  341
+      (Update done with the permission of cjm)
  342
+
  343
+Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>)
  344
+    - Added support for IRC DCC (ee)
  345
+    - Changed the aliasing routines to use ANSI style throughout -
  346
+      minor API changes for integration with other programs than PPP (ee)
  347
+    - Changed the build process, making all options switchable
  348
+      from the Makefile (ee)
  349
+    - Fixed minor security hole in alias_ftp.c for other applications
  350
+      of the aliasing software.  Hole could _not_ manifest in
  351
+      PPP+pktAlias, but could potentially manifest in other
  352
+      applications of the aliasing. (ee)
  353
+    - Connections initiated from packet aliasing host machine will
  354
+      not have their port number aliased unless it conflicts with
  355
+      an aliasing port already being used. (There is an option to
  356
+      disable this for debugging) (cjm)
  357
+    - Sockets will be allocated in cases where there might be
  358
+      port interference with the host machine.  This can be disabled
  359
+      in cases where the ppp host will be acting purely as a 
  360
+      masquerading router and not generate any traffic of its own.
  361
+      (cjm)
  362
+
  363
+Version 2.0: March, 1997 (cjm)
  364
+    - Incoming packets which are not recognised by the packet
  365
+      aliasing engine are now completely dropped in ip.c.
  366
+    - Aliasing links are cleared when a host interface address
  367
+      changes (due to re-dial and dynamic address allocation).
  368
+    - PacketAliasPermanentLink() API added.
  369
+    - Option for only aliasing private, unregistered IP addresses
  370
+      added.
  371
+    - Substantial rework to the aliasing lookup engine.
  372
+
  373
+Version 2.1: May, 1997 (cjm)
  374
+    - Continuing rework to the aliasing lookup engine to support
  375
+      multiple incoming addresses and static NAT.
  376
+    - Now supports outgoing as well as incoming ICMP error messages/
  377
+    - PPP commands to support address and port redirection.
  378
+
2  freebsd4/usr.sbin/ppp/acf.c
@@ -23,7 +23,7 @@
23 23
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 24
  * SUCH DAMAGE.
25 25
  *
26  
- * $FreeBSD: src/usr.sbin/ppp/acf.c,v 1.4.2.1 2000/08/19 09:29:59 brian Exp $
  26
+ * $FreeBSD: src/usr.sbin/ppp/acf.c,v 1.5 2000/07/19 02:10:30 brian Exp $
27 27
  */
28 28
 
29 29
 #include <sys/types.h>
28  freebsd4/usr.sbin/ppp/arp.c
@@ -17,7 +17,7 @@
17 17
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 18
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 19
  *
20  
- * $FreeBSD: src/usr.sbin/ppp/arp.c,v 1.37.2.1 2000/03/21 10:22:58 brian Exp $
  20
+ * $FreeBSD: src/usr.sbin/ppp/arp.c,v 1.41 2001/08/14 16:05:50 brian Exp $
21 21
  *
22 22
  */
23 23
 
@@ -57,13 +57,16 @@
57 57
 #include "slcompress.h"
58 58
 #include "lqr.h"
59 59
 #include "hdlc.h"
  60
+#include "ncpaddr.h"
60 61
 #include "ipcp.h"
61  
-#include "filter.h"
  62
+#include "ipv6cp.h"
62 63
 #include "descriptor.h"
63 64
 #include "lcp.h"
64 65
 #include "ccp.h"
65 66
 #include "link.h"
66 67
 #include "mp.h"
  68
+#include "ncp.h"
  69
+#include "filter.h"
67 70
 #ifndef NORADIUS
68 71
 #include "radius.h"
69 72
 #endif
@@ -104,7 +107,7 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
104 107
    */
105 108
 
106 109
   memset(&arpmsg, 0, sizeof arpmsg);
107  
-  if (!get_ether_addr(s, addr, &arpmsg.hwa)) {
  110
+  if (!arp_EtherAddr(s, addr, &arpmsg.hwa, 0)) {
108 111
     log_Printf(LogWARN, "%s: Cannot determine ethernet address for proxy ARP\n",
109 112
 	       inet_ntoa(addr));
110 113
     return 0;
@@ -144,7 +147,6 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add, int s)
144 147
 int
145 148
 arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
146 149
 {
147  
-
148 150
   return (arp_ProxySub(bundle, addr, 1, s));
149 151
 }
150 152
 
@@ -154,7 +156,6 @@ arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
154 156
 int
155 157
 arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
156 158
 {
157  
-
158 159
   return (arp_ProxySub(bundle, addr, 0, s));
159 160
 }
160 161
 
@@ -178,8 +179,9 @@ arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
178 179
    * Get the hardware address of an interface on the same subnet as our local
179 180
    * address.
180 181
    */
181  
-  if (!get_ether_addr(s, addr, &dls.sdl)) {
182  
-    log_Printf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
  182
+  if (!arp_EtherAddr(s, addr, &dls.sdl, 1)) {
  183
+    log_Printf(LOG_PHASE_BIT, "Cannot determine ethernet address for "
  184
+               "proxy ARP\n");
183 185
     return 0;
184 186
   }
185 187
   arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
@@ -219,12 +221,13 @@ arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
219 221
 
220 222
 
221 223
 /*
222  
- * get_ether_addr - get the hardware address of an interface on the
  224
+ * arp_EtherAddr - get the hardware address of an interface on the
223 225
  * the same subnet as ipaddr.
224 226
  */
225 227
 
226 228
 int
227  
-get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
  229
+arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr,
  230
+              int verbose)
228 231
 {
229 232
   int mib[6], skip;
230 233
   size_t needed;
@@ -242,7 +245,7 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
242 245
   mib[5] = 0;
243 246
 
244 247
   if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
245  
-    log_Printf(LogERROR, "get_ether_addr: sysctl: estimate: %s\n",
  248
+    log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n",
246 249
               strerror(errno));
247 250
     return 0;
248 251
   }
@@ -298,8 +301,9 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
298 301
 
299 302
         if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) ==
300 303
             (ipaddr.s_addr & netmask->sin_addr.s_addr)) {
301  
-          log_Printf(LogPHASE, "Found interface %.*s for %s\n",
302  
-                    dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
  304
+          log_Printf(verbose ? LogPHASE : LogDEBUG,
  305
+                     "Found interface %.*s for %s\n", dl->sdl_alen,
  306
+                     dl->sdl_data, inet_ntoa(ipaddr));
303 307
           memcpy(hwaddr, dl, dl->sdl_len);
304 308
           free(buf);
305 309
           return 1;
45  freebsd4/usr.sbin/ppp/arp.h
... ...
@@ -1,24 +1,31 @@
1  
-/*
2  
- *			User Process PPP
  1
+/*-
  2
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
  3
+ *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
  4
+ *                           Internet Initiative Japan, Inc (IIJ)
  5
+ * All rights reserved.
3 6
  *
4  
- *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
  7
+ * Redistribution and use in source and binary forms, with or without
  8
+ * modification, are permitted provided that the following conditions
  9
+ * are met:
  10
+ * 1. Redistributions of source code must retain the above copyright
  11
+ *    notice, this list of conditions and the following disclaimer.
  12
+ * 2. Redistributions in binary form must reproduce the above copyright
  13
+ *    notice, this list of conditions and the following disclaimer in the
  14
+ *    documentation and/or other materials provided with the distribution.
5 15
  *
6  
- *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7  
- *
8  
- * Redistribution and use in source and binary forms are permitted
9  
- * provided that the above copyright notice and this paragraph are
10  
- * duplicated in all such forms and that any documentation,
11  
- * advertising materials, and other materials related to such
12  
- * distribution and use acknowledge that the software was developed
13  
- * by the Internet Initiative Japan, Inc.  The name of the
14  
- * IIJ may not be used to endorse or promote products derived
15  
- * from this software without specific prior written permission.
16  
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  
- *
20  
- * $FreeBSD: src/usr.sbin/ppp/arp.h,v 1.9 1999/08/28 01:18:15 peter Exp $
  16
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26
+ * SUCH DAMAGE.
21 27
  *
  28
+ * $FreeBSD: src/usr.sbin/ppp/arp.h,v 1.11 2001/07/31 15:19:07 brian Exp $
22 29
  */
23 30
 
24 31
 struct sockaddr_dl;
@@ -26,4 +33,4 @@ struct bundle;
26 33
 
27 34
 extern int arp_ClearProxy(struct bundle *, struct in_addr, int);
28 35
 extern int arp_SetProxy(struct bundle *, struct in_addr, int);
29  
-extern int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
  36
+extern int arp_EtherAddr(int, struct in_addr, struct sockaddr_dl *, int);
44  freebsd4/usr.sbin/ppp/async.c
... ...
@@ -1,25 +1,33 @@
1  
-/*
2  
- *	             PPP Async HDLC Module
3  
- *
4  
- *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
  1
+/*-
  2
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
  3
+ *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
  4
+ *                           Internet Initiative Japan, Inc (IIJ)
  5
+ * All rights reserved.
5 6
  *
6  
- *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
  7
+ * Redistribution and use in source and binary forms, with or without
  8
+ * modification, are permitted provided that the following conditions
  9
+ * are met:
  10
+ * 1. Redistributions of source code must retain the above copyright
  11
+ *    notice, this list of conditions and the following disclaimer.
  12
+ * 2. Redistributions in binary form must reproduce the above copyright
  13
+ *    notice, this list of conditions and the following disclaimer in the
  14
+ *    documentation and/or other materials provided with the distribution.
7 15
  *
8  
- * Redistribution and use in source and binary forms are permitted
9  
- * provided that the above copyright notice and this paragraph are
10  
- * duplicated in all such forms and that any documentation,
11  
- * advertising materials, and other materials related to such
12  
- * distribution and use acknowledge that the software was developed
13  
- * by the Internet Initiative Japan, Inc.  The name of the
14  
- * IIJ may not be used to endorse or promote products derived
15  
- * from this software without specific prior written permission.
16  
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  
- *
20  
- * $FreeBSD: src/usr.sbin/ppp/async.c,v 1.23 1999/12/20 20:29:40 brian Exp $
  16
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26
+ * SUCH DAMAGE.
21 27
  *
  28
+ * $FreeBSD: src/usr.sbin/ppp/async.c,v 1.24 2001/06/13 21:52:15 brian Exp $
22 29
  */
  30
+
23 31
 #include <sys/types.h>
24 32
 
25 33
 #include <string.h>
235  freebsd4/usr.sbin/ppp/atm.c
... ...
@@ -0,0 +1,235 @@
  1
+/*-
  2
+ * Copyright (c) 2000 Jakob Stoklund Olesen <stoklund@taxidriver.dk>
  3
+ * All rights reserved.
  4
+ *
  5
+ * Redistribution and use in source and binary forms, with or without
  6
+ * modification, are permitted provided that the following conditions
  7
+ * are met:
  8
+ * 1. Redistributions of source code must retain the above copyright
  9
+ *    notice, this list of conditions and the following disclaimer.
  10
+ * 2. Redistributions in binary form must reproduce the above copyright
  11
+ *    notice, this list of conditions and the following disclaimer in the
  12
+ *    documentation and/or other materials provided with the distribution.
  13
+ *
  14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24
+ * SUCH DAMAGE.
  25
+ *
  26
+ * $FreeBSD: src/usr.sbin/ppp/atm.c,v 1.4 2001/06/18 14:59:30 brian Exp $
  27
+ */
  28
+
  29
+#include <sys/types.h>
  30
+#include <sys/socket.h>
  31
+#include <net/if.h>
  32
+#include <netnatm/natm.h>
  33
+
  34
+#include <errno.h>
  35
+#include <stdio.h>
  36
+#include <stdlib.h>
  37
+#include <string.h>
  38
+#include <sysexits.h>
  39
+#include <sys/uio.h>
  40
+#include <termios.h>
  41
+#include <unistd.h>
  42
+
  43
+#include "layer.h"
  44
+#include "defs.h"
  45
+#include "mbuf.h"
  46
+#include "log.h"
  47
+#include "timer.h"
  48
+#include "lqr.h"
  49
+#include "hdlc.h"
  50
+#include "throughput.h"
  51
+#include "fsm.h"
  52
+#include "lcp.h"
  53
+#include "ccp.h"
  54
+#include "link.h"
  55
+#include "async.h"
  56
+#include "descriptor.h"
  57
+#include "physical.h"
  58
+#include "main.h"
  59
+#include "atm.h"
  60
+
  61
+/* String identifying PPPoA */
  62
+#define PPPOA		"PPPoA"
  63
+#define PPPOA_LEN	(sizeof(PPPOA) - 1)
  64
+
  65
+struct atmdevice {
  66
+  struct device dev;		/* What struct physical knows about */
  67
+};
  68
+
  69
+#define device2atm(d) ((d)->type == ATM_DEVICE ? (struct atmdevice *)d : NULL)
  70
+
  71
+int
  72
+atm_DeviceSize(void)
  73
+{
  74
+  return sizeof(struct atmdevice);
  75
+}
  76
+
  77
+static ssize_t
  78
+atm_Sendto(struct physical *p, const void *v, size_t n)
  79
+{
  80
+  ssize_t ret = write(p->fd, v, n);
  81
+  if (ret < 0) {
  82
+    log_Printf(LogDEBUG, "atm_Sendto(%ld): %s\n", (long)n, strerror(errno));
  83
+    return ret;
  84
+  }
  85
+  return ret;
  86
+}
  87
+
  88
+static ssize_t
  89
+atm_Recvfrom(struct physical *p, void *v, size_t n)
  90
+{
  91
+    ssize_t ret = read(p->fd, (char*)v, n);
  92
+    if (ret < 0) {
  93
+      log_Printf(LogDEBUG, "atm_Recvfrom(%ld): %s\n", (long)n, strerror(errno));
  94
+      return ret;
  95
+    }
  96
+    return ret;
  97
+}
  98
+
  99
+static void
  100
+atm_Free(struct physical *p)
  101
+{
  102
+  struct atmdevice *dev = device2atm(p->handler);
  103
+
  104
+  free(dev);
  105
+}
  106
+
  107
+static void
  108
+atm_device2iov(struct device *d, struct iovec *iov, int *niov,
  109
+               int maxiov, int *auxfd, int *nauxfd)
  110
+{
  111
+  int sz = physical_MaxDeviceSize();
  112
+
  113
+  iov[*niov].iov_base = realloc(d, sz);
  114
+  if (iov[*niov].iov_base == NULL) {
  115
+    log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
  116
+    AbortProgram(EX_OSERR);
  117
+  }
  118
+  iov[*niov].iov_len = sz;
  119
+  (*niov)++;
  120
+}
  121
+
  122
+static const struct device baseatmdevice = {
  123
+  ATM_DEVICE,
  124
+  "atm",
  125
+  0,
  126
+  { CD_NOTREQUIRED, 0 },
  127
+  NULL,
  128
+  NULL,
  129
+  NULL,
  130
+  NULL,
  131
+  NULL,
  132
+  NULL,
  133
+  atm_Free,
  134
+  atm_Recvfrom,
  135
+  atm_Sendto,
  136
+  atm_device2iov,
  137
+  NULL,
  138
+  NULL
  139
+};
  140
+
  141
+struct device *
  142
+atm_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
  143
+               int maxiov, int *auxfd, int *nauxfd)
  144
+{
  145
+  if (type == ATM_DEVICE) {
  146
+    struct atmdevice *dev = (struct atmdevice *)iov[(*niov)++].iov_base;
  147
+
  148
+    dev = realloc(dev, sizeof *dev);	/* Reduce to the correct size */
  149
+    if (dev == NULL) {
  150
+      log_Printf(LogALERT, "Failed to allocate memory: %d\n",
  151
+                 (int)(sizeof *dev));
  152
+      AbortProgram(EX_OSERR);
  153
+    }
  154
+
  155
+    /* Refresh function pointers etc */
  156
+    memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev);
  157
+
  158
+    physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
  159
+    return &dev->dev;
  160
+  }
  161
+
  162
+  return NULL;
  163
+}
  164
+
  165
+static struct atmdevice *
  166
+atm_CreateDevice(struct physical *p, const char *iface, unsigned vpi,
  167
+                 unsigned vci)
  168
+{
  169
+  struct atmdevice *dev;
  170
+  struct sockaddr_natm sock;
  171
+  
  172
+  if ((dev = calloc(1, sizeof *dev)) == NULL) {
  173
+    log_Printf(LogWARN, "%s: Cannot allocate an atm device: %s\n",
  174
+               p->link.name, strerror(errno));
  175
+    return NULL;
  176
+  }
  177
+
  178
+  sock.snatm_len = sizeof sock;
  179
+  sock.snatm_family = AF_NATM;
  180
+  strncpy(sock.snatm_if, iface, IFNAMSIZ);
  181
+  sock.snatm_vpi = vpi;
  182
+  sock.snatm_vci = vci;
  183
+
  184
+  log_Printf(LogPHASE, "%s: Connecting to %s:%u.%u\n", p->link.name,
  185
+             iface, vpi, vci);
  186
+
  187
+  p->fd = socket(PF_NATM, SOCK_DGRAM, PROTO_NATMAAL5);
  188
+  if (p->fd >= 0) {
  189
+    log_Printf(LogDEBUG, "%s: Opened atm socket %s\n", p->link.name,
  190
+               p->name.full);
  191
+    if (connect(p->fd, (struct sockaddr *)&sock, sizeof sock) == 0)
  192
+      return dev;
  193
+    else
  194
+      log_Printf(LogWARN, "%s: connect: %s\n", p->name.full, strerror(errno));
  195
+  } else
  196
+    log_Printf(LogWARN, "%s: socket: %s\n", p->name.full, strerror(errno));
  197
+
  198
+  close(p->fd);
  199
+  p->fd = -1;
  200
+  free(dev);
  201
+
  202
+  return NULL;
  203
+}
  204
+
  205
+struct device *
  206
+atm_Create(struct physical *p)
  207
+{
  208
+  struct atmdevice *dev;
  209
+
  210
+  dev = NULL;
  211
+  if (p->fd < 0 && !strncasecmp(p->name.full, PPPOA, PPPOA_LEN)
  212
+      && p->name.full[PPPOA_LEN] == ':') {
  213
+    char iface[25];
  214
+    unsigned vci, vpi;
  215
+    
  216
+    if (sscanf(p->name.full + PPPOA_LEN + 1, "%25[A-Za-z0-9]:%u.%u", iface,
  217
+               &vpi, &vci) != 3) {
  218
+      log_Printf(LogWARN, "Malformed ATM device name \'%s\', "
  219
+                 "PPPoA:if:vpi.vci expected\n", p->name.full);
  220
+      return NULL;
  221
+    }
  222
+    
  223
+    dev = atm_CreateDevice(p, iface, vpi, vci);
  224
+  }
  225
+
  226
+  if (dev) {
  227
+    memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev);
  228
+    physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
  229
+    if (p->cfg.cd.necessity != CD_DEFAULT)
  230
+      log_Printf(LogWARN, "Carrier settings ignored\n");
  231
+    return &dev->dev;
  232
+  }
  233
+
  234
+  return NULL;
  235
+}
35  freebsd4/usr.sbin/ppp/atm.h
... ...
@@ -0,0 +1,35 @@
  1
+/*-
  2
+ * Copyright (c) 2000 Jakob Stoklund Olesen <stoklund@taxidriver.dk>
  3
+ * All rights reserved.
  4
+ *
  5
+ * Redistribution and use in source and binary forms, with or without
  6
+ * modification, are permitted provided that the following conditions
  7
+ * are met:
  8
+ * 1. Redistributions of source code must retain the above copyright
  9
+ *    notice, this list of conditions and the following disclaimer.
  10
+ * 2. Redistributions in binary form must reproduce the above copyright
  11
+ *    notice, this list of conditions and the following disclaimer in the
  12
+ *    documentation and/or other materials provided with the distribution.
  13
+ *
  14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24
+ * SUCH DAMAGE.
  25
+ *
  26
+ * $FreeBSD: src/usr.sbin/ppp/atm.h,v 1.1 2000/09/14 22:02:54 brian Exp $
  27
+ */
  28
+
  29
+struct physical;
  30
+struct device;
  31
+
  32
+extern struct device *atm_Create(struct physical *);
  33
+extern struct device *atm_iov2device(int, struct physical *,
  34
+                                     struct iovec *, int *, int, int *, int *);
  35
+extern int atm_DeviceSize(void);
51  freebsd4/usr.sbin/ppp/auth.c
... ...
@@ -1,31 +1,38 @@
1  
-/*
2  
- *			PPP Secret Key Module
  1
+/*-
  2
+ * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
  3
+ *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
  4
+ *                           Internet Initiative Japan, Inc (IIJ)
  5
+ * All rights reserved.
3 6
  *
4  
- *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
  7
+ * Redistribution and use in source and binary forms, with or without
  8
+ * modification, are permitted provided that the following conditions
  9
+ * are met:
  10
+ * 1. Redistributions of source code must retain the above copyright
  11
+ *    notice, this list of conditions and the following disclaimer.
  12
+ * 2. Redistributions in binary form must reproduce the above copyright
  13
+ *    notice, this list of conditions and the following disclaimer in the
  14
+ *    documentation and/or other materials provided with the distribution.
5 15
  *
6  
- *   Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
  16
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26
+ * SUCH DAMAGE.
7 27
  *
8  
- * Redistribution and use in source and binary forms are permitted
9  
- * provided that the above copyright notice and this paragraph are
10  
- * duplicated in all such forms and that any documentation,
11  
- * advertising materials, and other materials related to such
12  
- * distribution and use acknowledge that the software was developed
13  
- * by the Internet Initiative Japan, Inc.  The name of the
14  
- * IIJ may not be used to endorse or promote products derived
15  
- * from this software without specific prior written permission.
16  
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  
- *
20  
- * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.50 1999/12/27 11:43:30 brian Exp $
21  
- *
22  
- *	TODO:
23  
- *		o Implement check against with registered IP addresses.
  28
+ * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.52 2001/08/14 16:05:50 brian Exp $
24 29
  */
  30
+
25 31
 #include <sys/param.h>
26 32
 #include <netinet/in.h>
27 33
 #include <netinet/in_systm.h>
28 34
 #include <netinet/ip.h>
  35
+#include <sys/socket.h>
29 36
 #include <sys/un.h>
30 37
 
31 38
 #include <pwd.h>
@@ -45,6 +52,8 @@
45 52
 #include "slcompress.h"
46 53
 #include "lqr.h"
47 54
 #include "hdlc.h"