Commit Graph

1425 Commits

Author SHA1 Message Date
Brian Somers
c3805e0152 Detect if a udp socket on STDIN_FILENO is connected by calling
getpeername() and don't set PASSIVE mode if it's is.
2002-01-23 23:36:35 +00:00
Brian Somers
97dd5500aa Cross reference the NETWORK ADDRESS TRANSLATION section when describing
the -nat flag.

Requested by:	eivind
2002-01-23 21:11:33 +00:00
Brian Somers
63c6cac940 socket()s first argument should be a protocol family rather than an
address family.
2002-01-16 14:03:52 +00:00
Brian Somers
c87436f341 socket's first argument is an address family, not a protocol family. 2002-01-16 13:15:47 +00:00
Brian Somers
af1e766495 When authenticating a name containing a ``\'', attempt to autenticate
using the part after the ``\'' if the original name is not found.

This allows M$ clients to use domain\user as their authname.

Reviewed by: Ian West <ian@niw.com.au>
2002-01-08 11:24:39 +00:00
Brian Somers
c03b8e5e60 Consider PROTO_IPV6 as compressible by CCP.
Spotted by: Nick Sayer <nsayer@quack.kfu.com>
2001-12-09 01:29:12 +00:00
Brian Somers
add3c04151 Pay attention to failures to SIOCAIFADDR and SIOCDIFFADDR. 2001-11-30 14:01:21 +00:00
Brian Somers
c4a913b6b8 Don't provide an RTA_GATEWAY sockaddr when we write RTM_CHANGE messages
to the routing socket.

The local address on a point-to-point interface is not actually a
gateway address - despite it appearing in the second column of
netstat -r's output.  Providing a gateway to an RTM_CHANGE will
currently change the route's interface so that it's using the
specified gateway - not what we want.

Patiently explained to me by:	ru
2001-11-30 14:01:20 +00:00
Brian Somers
2ea80d6d37 Add some DEBUG logging to tell us when interface addresses are being
added and removed
2001-11-30 14:01:18 +00:00
Brian Somers
0ed9882caa Remove the hack that ensures that rt_Update() works on FreeBSD. Now
that the ncpaddr code doesn't create default routes with non-zero
masks, everything works as it should.
2001-11-23 19:20:45 +00:00
Brian Somers
361a7b933f When writing messages to the routing socket, round sockaddr sizes
up in the same way that we expect them to be when we read them.

This is a no-op on i386 and probably on alphas, as we currently
only support AF_INET and AF_INET6.
2001-11-23 17:19:36 +00:00
Brian Somers
a3d71c3de1 Be paranoid about non-zero netmasks being associated with INET addresses
of 0.0.0.0.

The OpenBSD PF_ROUTE/NET_RT_DUMP sysctl is sending back routes with
RTAX_NETMASK set, but the corresponding sockaddr being 4 zero bytes
(with an address family of zero).  ppp was getting confused by this
and ending up interpreting it as a 0.0.0.0/32 routing table
destination and subsequently failing to do anything with the route.

Specifically, after this fix, ppp under OpenBSD can successfully
change and delete the default route again !
2001-11-23 17:19:27 +00:00
Brian Somers
846e7227be Remove an unused variable (oops) 2001-11-23 15:47:04 +00:00
Brian Somers
26dceef0a6 Don't adjust_linklocal() when pulling a sockaddr out of an ncpaddr or
ncprange structure.

Don't write() the netmask for IPv6 sockaddrs to the routing socket if
the prefixlen is 128.

It seems that messages written to the routing socket with the scopeid
set for link local addresses are not understood.  Instead, we have to
put the scopeid in the 5th and 6th bytes of the address (see
adjust_linklocal() in ncpaddr.c).  I think this may be a bug in the
KAME implementation - it should really understand both forms.
2001-11-23 12:39:20 +00:00
Brian Somers
412649a38d Remove a bogus log_Id() decl 2001-11-23 11:15:35 +00:00
Brian Somers
eea438f87a Fix usage for the log command 2001-11-23 11:07:43 +00:00
Brian Somers
a1c634637f Whitespace tweak 2001-11-23 10:46:28 +00:00
Brian Somers
a12856cfee Expand the first argument of the ``log'' command if it's a variable. 2001-11-22 04:23:49 +00:00
Brian Somers
3b0c289136 Document that an UPTIME variable is now available 2001-11-22 01:44:23 +00:00
Brian Somers
39d2e655ee Remove unused variables 2001-11-04 16:19:05 +00:00
Brian Somers
46df5aa7bc Add a ``log'' command for logging specific information.
Add an ``UPTIME'' variable to indicate the bundle uptime.

It's now possible to put something like this in ppp.linkdown
for a server setup:

  MYADDR:
    log Session closing: User USER, address HISADDR, up UPTIME

Fixed some memory leakage with commands that expand words.
Made some functions static.
Fixed a diagnostic bug (iface add .... SIOCDIFADDR)
2001-11-03 21:45:32 +00:00
Brian Somers
9ea6970784 Call CCP protocol -1 ``none'' 2001-11-03 19:29:30 +00:00
Brian Somers
de97d73d11 cmott@scientech.com -> cm@linktel.net
Requested by: Charless Mott <cmott@scientech.com>
2001-11-03 11:36:17 +00:00
Brian Somers
dad51e5ce8 Don't avoid setting a 0 second timer in datalink_StartDialTimer() by
not setting any timer.  Instead, set a 1 millisecond timer.

This ensures that ppp will come out of it's select() call after
losing carrier in -ddial mode with a reconnect period of 0 and
going to ST_OPENING, rather than waiting indefinitely for some
other event to wake ppp up.

Bump the ppp version number to indicate the event.

MFC after: 3 days
2001-10-23 13:52:19 +00:00
Peter Wemm
0407540adf ia64 support. Due to the bogus placement of some i4b includes, it is
i386-only, even though it would work on all the isa-capable platforms.
Change the NOI4B so that instead of excluding alpha, it only includes i386.
2001-10-23 10:20:24 +00:00
Brian Somers
0860ce5d69 Include the right i4b files for NetBSD 2001-10-19 15:56:56 +00:00
Brian Somers
542a7fe08a Fix AUTH callback negotiations.
MFC after: 1 week
2001-10-18 08:48:04 +00:00
Brian Somers
2a772845ff When the peer fails to specify an MRU and a 1500 byte MRU is not
allowed either because of the transport or configuration, send a
MRU NAK only once, then allow the negotiations to proceed.

rfc1661 says that 1500 should always be allowed and rfc2516 says
that 1492 is the maximum for PPPoE.  This changes ppp so that it
only weakly suggests 1492, then goes with the default (leaving
the problem in the hands of the peer WRT how they set their MTU).

MFC after: 1 week
2001-10-18 08:47:56 +00:00
David Malone
2bc21ed985 Hopefully improve control message passing over Unix domain sockets.
1) Allow the sending of more than one control message at a time
over a unix domain socket. This should cover the PR 29499.

2) This requires that unp_{ex,in}ternalize and unp_scan understand
mbufs with more than one control message at a time.

3) Internalize and externalize used to work on the mbuf in-place.
This made life quite complicated and the code for sizeof(int) <
sizeof(file *) could end up doing the wrong thing. The patch always
create a new mbuf/cluster now. This resulted in the change of the
prototype for the domain externalise function.

4) You can now send SCM_TIMESTAMP messages.

5) Always use CMSG_DATA(cm) to determine the start where the data
in unp_{ex,in}ternalize. It was using ((struct cmsghdr *)cm + 1)
in some places, which gives the wrong alignment on the alpha.
(NetBSD made this fix some time ago).

This results in an ABI change for discriptor passing and creds
passing on the alpha. (Probably on the IA64 and Spare ports too).

6) Fix userland programs to use CMSG_* macros too.

7) Be more careful about freeing mbufs containing (file *)s.
This is made possible by the prototype change of externalise.

PR:		29499
MFC after:	6 weeks
2001-10-04 13:11:48 +00:00
Ruslan Ermilov
72736552c4 Keep up with sys/net/rtsock.c,v 1.58.
Prodded by:	brian
2001-09-21 16:14:53 +00:00
Brian Somers
ed1e8460bd sigpause() -> sigsuspend()
sigblock() -> sigprocmask()
2001-09-13 10:03:30 +00:00
Brian Somers
d9dc3116bf Correct alignment issues
Obtained from: OpenBSD
2001-09-13 10:03:20 +00:00
Brian Somers
ee52a08baa Spell syslog.conf correctly
Submitted by:	Tony Finch <dot@dotat.at>
PR:		30545
2001-09-13 09:06:51 +00:00
Brian Somers
156a04e466 Fix a diagnostic 2001-09-04 22:07:56 +00:00
Brian Somers
f0ea3513c9 Some cosmetic changes to sync with OpenBSD 2001-08-27 19:08:43 +00:00
Brian Somers
a7428f1858 Send a reset request for every packet received when our encryption
dictionaries are out of sync.

This avoids the complications that happen when our original reset
request gets lost in transit (quite likely in hind sight, given a
lossy link) when we end up ignoring the peer for the next (up to)
256 packets.

Submitted by:	Nick Sayer <nsayer@quack.kfu.com>
2001-08-27 10:42:21 +00:00
Brian Somers
1a939a075f Handle return values of 0 from NgRecvMsg() properly. 2001-08-24 14:53:41 +00:00
Brian Somers
ebdcbc6744 o Enable IFF_MULTICAST when first opening the tun device (and keep the flag
when we ioctl(TUNSIFINFO) under OpenBSD)
o Don't bring the interface up immediately
o Don't complain about unrecognised interface flags in ``show iface''.
2001-08-21 11:07:58 +00:00
Brian Somers
2313781df2 Handle snprintf() returning < 0 (not just -1)
MFC after:	2 weeks
2001-08-20 15:09:34 +00:00
Brian Somers
84b0fe8197 Properly change old interface addresses so that their destination is
255.255.255.255 if our new destination address conflicts.
2001-08-20 11:06:21 +00:00
Brian Somers
428217f76c Add some comments to explain what's going on here 2001-08-20 10:25:23 +00:00
Brian Somers
d42d9220c7 When attempting to change the default route, don't write the gateway
and mask to the routing socket, otherwise the update fails.

Warning provided by: markm

The code here was broken for FreeBSD when IPv6 support was added, but
was fixed for OpenBSD.  OpenBSD expects the gateway and mask to be
supplied and fails the update otherwise.
2001-08-20 00:46:33 +00:00
Brian Somers
260799afa4 Add some casts.
Not spotted by: FreeBSD's gcc version 2.95.3 20010315 (release)
Spotted by: OpenBSD's gcc version 2.95.3 20010125 (prerelease)
2001-08-19 22:23:28 +00:00
Brian Somers
5cbe92e7e8 Add a missing % in a format string.
Not spotted by: FreeBSD's gcc version 2.95.3 20010315 (release)
Spotted by: OpenBSD's gcc version 2.95.3 20010125 (prerelease)
2001-08-19 22:23:23 +00:00
Brian Somers
856cf6873b Avoid a compiler warning
Not spotted by: FreeBSD's gcc version 2.95.3 20010315 (release)
Spotted by: OpenBSD's gcc version 2.95.3 20010125 (prerelease)
2001-08-19 22:23:22 +00:00
Brian Somers
1433aa5dff Better handling for the return of snprintf(). 2001-08-18 22:43:11 +00:00
Brian Somers
1a2b4e4a5c If AF_INET6 isn't available in the kernel, revert to creating AF_INET
listening sockets in ``set server''.
2001-08-18 19:16:56 +00:00
Brian Somers
1136c6ac64 Back out the previous fix to deal with kernels that don't support IPv6,
and implement a far more subtle and correct fix.

The reason behind the infinite loop was that ppp was trying to make up
initial IPv6 numbers and wasn't giving up when it failed unexpectedly to
assign the addresses it just fabricated to it's interface (thinking that
the reason was because another interface was using the same address).
It now attempts this up to 100 times before just failing and trying to
muddle along (in reality, this should never happen more than a couple
of times unless our random number generator doesn't work).

Also, when IPv6 is not available, don't even try to assign the IPv6
interface address in the first place...
2001-08-18 19:07:13 +00:00
Brian Somers
c5109a323c Run correctly on a machine built without AF_INET6 support 2001-08-18 13:04:52 +00:00
Brian Somers
1d3d76d47f Build properly with -DNOINET6 2001-08-18 12:31:54 +00:00
Brian Somers
6c764d89cd Build properly with -DNOIPV6 2001-08-18 12:30:41 +00:00
Brian Somers
cb41bad03f Add two missing includes 2001-08-16 16:58:12 +00:00
Brian Somers
e1a94c3dcf Remove an unused variable 2001-08-16 16:58:02 +00:00
Ruslan Ermilov
8ab59f7093 mdoc(7) police: markup nit, removed whitespace at EOL. 2001-08-16 08:26:04 +00:00
Brian Somers
5ae083292b Specify the gateway address when updating the MTU and send/recv pipe
sizes on a route.

IMHO this shouldn't be necessary (the destination & mask/prefixlen
should be enough), but without it, the default route update under
OpenBSD will fail.

Thanks to: Russell T Hunt <alaric@MIT.EDU>
2001-08-16 02:01:05 +00:00
Brian Somers
6de54bbe7a Fix a couple of forgotten comments 2001-08-16 02:00:55 +00:00
Brian Somers
971abb295e Probe for the availability of AF_INET6 at startup. If it's not
available, default ipv6cp to disabled and refuse to let the user
enable it.
2001-08-15 13:53:38 +00:00
Brian Somers
a886247185 Don't show a prefixlen when a destination address is present
in ``show iface''.
2001-08-15 13:05:39 +00:00
Brian Somers
ad1f9eaedb Add a missing newline 2001-08-15 12:48:09 +00:00
Brian Somers
bcd13e2e67 Don't forget to attache the sticky route change to the ncp structure.
PR:	29726
2001-08-15 12:47:51 +00:00
Brian Somers
2f4da197f1 Avoid calling bits2mask4() when bits is -1. 2001-08-15 12:07:39 +00:00
Brian Somers
30949fd4b5 o Add ipv6 support, abstracting most NCP addresses into opaque
structures (well, they're treated as opaque).

  It's now possible to manage IPv6 interface addresses and routing
  table entries and to filter IPV6 traffic whether encapsulated or
  not.

  IPV6CP support is crude for now, and hasn't been tested against
  any other implementations.

  RADIUS and IPv6 are independent of eachother for now.

  ppp.linkup/ppp.linkdown aren't currently used by IPV6CP

o Understand all protocols(5) in filter rules rather than only a select
  few.

o Allow a mask specification for the ``delete'' command.  It's now
  possible to specifically delete one of two conflicting routes.

o When creating and deleting proxy arp entries, do it for all IPv4
  interface addresses rather than doing it just for the ``current''
  peer address.

o When iface-alias isn't in effect, don't blow away manually (via ``iface
  add'') added interface addresses.

o When listening on a tcp server (diagnostic) socket, bind so that a
  tcp46 socket is created -- allowing both IPv4 and IPv6 connections.

o When displaying ICMP traffic, don't display the icmp type twice.
  When display traffic, display at least some information about unrecognised
  traffic.

o Bump version

Inspired after filtering work by: Makoto MATSUSHITA <matusita@jp.FreeBSD.org>
2001-08-14 16:05:52 +00:00
Ruslan Ermilov
04da392069 mdoc(7) police: s/OpenBSD/.Ox/ where appropriate. 2001-08-13 16:43:02 +00:00
Brian Somers
f48ce56286 Preprocess ppp.8.m4 into ppp.8, taking into account any compile time
options used to build ppp.

Currently, this is a no-op and only handles LOCALNAT and LOCALRAD cases.

This will be used for the upcoming ipv6 changes, and allows a shared
man page between OpenBSD and FreeBSD.
2001-08-11 18:27:14 +00:00
Brian Somers
915ce3bc2a Change copyright to BSD-style copyright.
Ok'd by:	Gabor Kincses <gabor@acm.org>
2001-08-10 17:42:58 +00:00
Ruslan Ermilov
c4d9468ea0 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
Brian Somers
d8c3658bb5 Warn when a CHAP81 SUCCESS packet is invalid due to an incorrect S= value. 2001-08-03 09:28:21 +00:00
Brian Somers
1a40cd082a The wrong-last-byte bug on win98 chap responses is also in winME 2001-08-02 20:12:48 +00:00
Brian Somers
686e8c8b12 Add a ``nat punch_fw'' command for punching FTP and IRC DCC holes through
the firewall.
2001-08-02 10:16:32 +00:00
Brian Somers
317e74fd2b Don't include a NUL at the end of our CHAP SUCCESS packet.
When encryption (MPPE) is enabled, WindowsME and Windows98 both
fail because of the extra byte, suggesting that they autheticated
successfully in their log and then dropping the connection, telling
the user that the peer doesn't support compatible encryption
options.

MFC after: 1 week
2001-07-31 21:36:00 +00:00
Brian Somers
65cacad456 Remove an irritating diagnostic emitted to LogPHASE when a
static proxy arp entry is deleted.

Rename a function (for consistency) and remove some whitespace
(for readability).

MFC after:	1 week
2001-07-31 15:19:07 +00:00
Brian Somers
ed09c8a4a0 When we receive a CHAP81 challenge response, we always expect the last
byte of the packet to contain '\0'.

Windows 98 gets this wrong, dropping garbage into the last byte and
failing authentication.

Now, we notice this and whinge to our log file that we're compensating
for the corrupt data.
2001-07-31 08:21:39 +00:00
Brian Somers
5a0827311e If the peer REJects our MRU REQ, stop REQing it -- *EVEN* if we're
doing PPPoE and the default MRU is therefore too big.

When negotiating with win2k, we ask for MRU 1492 and the win2k box
NAKs us saying ``MRU 1492''.  This doesn't make sense to me.  When
we continue to request MRU 1492, the win2k box eventually REJs our
MRU.  This fix allows negotiations to continue at that point,
bringing the link up and potentially allowing the win2k box to send
us frames that are too large.  AFAICT this is better than failing
to bring the link up.... probably !

I have no idea how to do the equivalent of ``route get'' or
``ifconfig -a'' under win2k, so I can't tell what MTU it actually
ends up using.

I believe the bug is in win2k (it's certainly mis-negotiating).
I'll MFC given the release engineers permission as code freeze
begins on August 1.

PR:		29277
MFC after:	3 days
2001-07-30 17:04:39 +00:00
Brian Somers
fe17bea378 Change permissions back to 4554/554
Suggested by:	kris
2001-07-28 11:58:41 +00:00
Brian Somers
5e3b2d6847 If the peer sends a REQ without the IPADDR option, only reject it
once.  If they repeat the request (again without the IPADDR option)
ACK it.

I've had reports that some ppp implementations will not assign
themselves an IP number.  This should negotiate with such things.

MFC after:	3 days
2001-07-28 11:32:08 +00:00
Brian Somers
525b58c9ce Handle peer REQ/NAKs of >1500 byte MRUs when we have no preference.
MFC after: 3 days
2001-07-26 11:33:53 +00:00
Brian Somers
1e0a94b6a0 Change permissions from [4]554 to [4]551
MFC after: 3 days
2001-07-25 11:44:04 +00:00
David E. O'Brien
90e655ea4e Perform a major cleanup of the usr.sbin Makefiles.
These are not perfectly in agreement with each other style-wise, but they
are orders of orders of magnitude more consistent style-wise than before.
2001-07-20 06:20:32 +00:00
David E. O'Brien
ac24b049cc Remove GCC'isms in CFLAGS. 2001-07-20 04:23:13 +00:00
Brian Somers
8152dca8b2 Bring the PPPoE Ethernet interface up *BEFORE* we send the node a
CONNECT message.

MFC after: 1 week
2001-07-18 09:33:45 +00:00
Brian Somers
17462195a8 Ignore (with a warning message) mtu/mru configurations that are greater
than the maximum physical values.

MFC after: 1 week
2001-07-17 01:06:13 +00:00
Brian Somers
c4498e7de4 TCPMSS adjusts all TCP SYN packets, not just outgoing ones.
Pointed out by: ru
2001-07-16 17:02:10 +00:00
Dima Dorfman
f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Brian Somers
6cee8a8317 Perform MSS fixups on incoming packets as well as outgoing.
MFC after: 1 week
2001-07-13 02:04:19 +00:00
Dima Dorfman
70d51341bf mdoc(7) police: remove extraneous .Pp before and/or after .Sh. 2001-07-09 09:54:33 +00:00
Brian Somers
b5b15b9e7f Fix the type of the last arg to execl()
Obtained from: OpenBSD
2001-07-09 08:17:47 +00:00
Brian Somers
543b7124d2 Staticise the OpenBSD SHA1_End() function 2001-07-09 00:45:57 +00:00
Brian Somers
4016f9e0c4 Stay (backwards-)compatible with OpenBSD's groff 2001-07-09 00:13:49 +00:00
Brian Somers
8829899405 Add a ``nat proto'' command -- similar to natd(8)'s -redirect_proto switch.
MFC after: 3 weeks
2001-07-09 00:07:56 +00:00
Brian Somers
7e62c63844 Don't try to dereference the -1th ccp algorithm array entry when we
open CCP with no algorithm.
2001-07-07 13:12:07 +00:00
Brian Somers
662a42f752 When we miss one or more packets in stateful mode *and* need to
perform a key change, *and* our sequence numbers have wrapped,
ensure that the number of key changes is calculated correctly.

The previous code counted down from a negative number to zero,
re-encrypting the current key on each iteration - this took some
time and strangely enough got the answer wrong !!!

Fix a(nother) spelling mistake while I'm there.
2001-07-07 03:06:20 +00:00
Brian Somers
80a18377e9 Spell stateful properly
Inconsistently done by:	brian
Spotted by:		ru
2001-07-06 23:45:32 +00:00
Ruslan Ermilov
8fa6936ded mdoc(7) police: removed hard sentence breaks, sorted xrefs. 2001-07-05 11:01:12 +00:00
Brian Somers
dd1a52b9e4 Make the last fix work properly on descriptors 1 and 2 (not just 0) 2001-07-04 09:32:34 +00:00
Brian Somers
108e336ab5 Handle any of descriptors 0, 1 or 2 being closed when we're
envoked -- don't use them (as return values from open()), then
(say) close(STDIN_FILENO) when daemonising.

This is done by grabbing 3 descriptors to /dev/null at startup and
releasing them after we've daemonised.

MFC after: 1 week
2001-07-04 03:34:20 +00:00
Brian Somers
6301d506fb Reduce the interface MTU by 2 when MPPE has been successfully negotiated.
This is necessary because MPPE will combine the protocol id with the
payload received on the tun interface, encrypt it, then prepend its
own protocol id, effectively increasing the payload by two bytes.
2001-07-03 22:20:19 +00:00
Brian Somers
4bb6aac05e Don't accept chap80lm by default - it doesn't work.
MFC after: 1 week
2001-07-03 22:20:11 +00:00
Brian Somers
f2e587a36c Silence some gcc warnings 2001-07-03 22:20:06 +00:00
Brian Somers
7aab014be6 Do away with the ``err'' variable.
Inspired by: kris
2001-07-03 01:02:26 +00:00
Kris Kennaway
0c50e5287e Silence some of the -Wnon-const-format warnings and add __printflike()
to a function prototype which needs it.

Approved by:	brian
MFC After:	2 weeks
2001-07-02 12:27:49 +00:00