Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/dhcp Patchlevel 27
details: https://anonhg.NetBSD.org/src/rev/a8538494052f
branches: trunk
changeset: 472275:a8538494052f
user: mellon <mellon%NetBSD.org@localhost>
date: Mon Apr 26 15:43:06 1999 +0000
description:
Patchlevel 27
diffstat:
usr.sbin/dhcp/common/dlpi.c | 5 ++
usr.sbin/dhcp/common/inet.c | 5 ++
usr.sbin/dhcp/common/packet.c | 84 ++++++++++++++++++++++++++++--------------
usr.sbin/dhcp/common/tables.c | 30 +++++++-------
usr.sbin/dhcp/includes/osdep.h | 8 ++--
usr.sbin/dhcp/relay/dhcrelay.c | 4 +-
usr.sbin/dhcp/server/db.c | 11 +++++-
7 files changed, 97 insertions(+), 50 deletions(-)
diffs (truncated from 307 to 300 lines):
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/common/dlpi.c
--- a/usr.sbin/dhcp/common/dlpi.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/common/dlpi.c Mon Apr 26 15:43:06 1999 +0000
@@ -82,6 +82,11 @@
* to sleep.
*/
+#ifndef lint
+static char copyright[] =
+"$Id: dlpi.c,v 1.1.1.5 1999/04/26 15:43:06 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+#endif /* not lint */
+
#include "dhcpd.h"
#if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/common/inet.c
--- a/usr.sbin/dhcp/common/inet.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/common/inet.c Mon Apr 26 15:43:06 1999 +0000
@@ -40,6 +40,11 @@
* Enterprises, see ``http://www.vix.com''.
*/
+#ifndef lint
+static char copyright[] =
+"$Id: inet.c,v 1.1.1.4 1999/04/26 15:43:07 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+#endif /* not lint */
+
#include "dhcpd.h"
/* Return just the network number of an internet address... */
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/common/packet.c
--- a/usr.sbin/dhcp/common/packet.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/common/packet.c Mon Apr 26 15:43:06 1999 +0000
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.1.1.5 1999/03/26 17:49:22 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.1.1.6 1999/04/26 15:43:07 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -72,6 +72,9 @@
debug ("sum = %x", sum);
#endif
sum += (u_int16_t) ntohs(*((u_int16_t *)(buf + i)));
+ /* Add carry. */
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
}
/* If there's a single byte left over, checksum it, too. Network
@@ -81,13 +84,15 @@
debug ("sum = %x", sum);
#endif
sum += buf [i] << 8;
+ /* Add carry. */
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
}
return sum;
}
-/* Fold the upper sixteen bits of the checksum down into the lower bits,
- complement the sum, and then put it into network byte order. */
+/* Finish computing the sum, and then put it into network byte order. */
u_int32_t wrapsum (sum)
u_int32_t sum;
@@ -96,17 +101,7 @@
debug ("wrapsum (%x)", sum);
#endif
- while (sum > 0x10000) {
- sum = (sum >> 16) + (sum & 0xFFFF);
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- sum += (sum >> 16);
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- }
- sum = sum ^ 0xFFFF;
+ sum = ~sum & 0xFFFF;
#ifdef DEBUG_CHECKSUM_VERBOSE
debug ("sum = %x", sum);
#endif
@@ -237,20 +232,25 @@
/* UDP header and IP header decoded together for convenience. */
-ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
+ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen)
struct interface_info *interface;
unsigned char *buf;
int bufix;
struct sockaddr_in *from;
unsigned char *data;
- int len;
+ int buflen;
{
struct ip *ip;
struct udphdr *udp;
u_int32_t ip_len = (buf [bufix] & 0xf) << 2;
u_int32_t sum, usum;
- static int packets_seen;
- static int packets_bad_checksum;
+ static int ip_packets_seen;
+ static int ip_packets_bad_checksum;
+ static int udp_packets_seen;
+ static int udp_packets_bad_checksum;
+ static int udp_packets_length_checked;
+ static int udp_packets_length_overflow;
+ int len;
ip = (struct ip *)(buf + bufix);
udp = (struct udphdr *)(buf + bufix + ip_len);
@@ -266,14 +266,23 @@
#endif /* USERLAND_FILTER */
/* Check the IP header checksum - it should be zero. */
+ ++ip_packets_seen;
if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
- if (packets_seen &&
- (++packets_seen / ++packets_bad_checksum) < 2)
- note ("Bad IP checksum: %x",
- wrapsum (checksum (buf + bufix, sizeof *ip, 0)));
+ ++ip_packets_bad_checksum;
+ if (ip_packets_seen > 4 &&
+ (ip_packets_seen / ip_packets_bad_checksum) < 2) {
+ note ("%d bad IP checksums seen in %d packets",
+ ip_packets_bad_checksum, ip_packets_seen);
+ ip_packets_seen = ip_packets_bad_checksum = 0;
+ }
return -1;
}
+ /* Check the IP packet length. */
+ if (ntohs (ip -> ip_len) != buflen)
+ debug ("ip length %d disagrees with bytes received %d.",
+ ntohs (ip -> ip_len), buflen);
+
/* Copy out the IP source address... */
memcpy (&from -> sin_addr, &ip -> ip_src, 4);
@@ -283,7 +292,23 @@
if (!data) {
data = buf + bufix + ip_len + sizeof *udp;
- len -= ip_len + sizeof *udp;
+ len = ntohs (udp -> uh_ulen) - sizeof *udp;
+ ++udp_packets_length_checked;
+ if (len + data > buf + bufix + buflen) {
+ ++udp_packets_length_overflow;
+ if (udp_packets_length_checked > 4 &&
+ (udp_packets_length_checked /
+ udp_packets_length_overflow) < 2) {
+ note ("%d udp packets in %d too long - dropped",
+ udp_packets_length_overflow,
+ udp_packets_length_checked);
+ udp_packets_length_overflow =
+ udp_packets_length_checked = 0;
+ }
+ return -1;
+ }
+ if (len + data != buf + bufix + buflen)
+ debug ("accepting packet with data after udp payload.");
}
usum = udp -> uh_sum;
@@ -298,12 +323,15 @@
(u_int32_t)
ntohs (udp -> uh_ulen)))));
+ udp_packets_seen++;
if (usum && usum != sum) {
- static int packets_seen;
- static int packets_bad_checksum;
- if (packets_seen &&
- (++packets_seen / ++packets_bad_checksum) < 2)
- note ("Bad udp checksum: %x %x", usum, sum);
+ udp_packets_bad_checksum++;
+ if (udp_packets_seen > 4 &&
+ (udp_packets_seen / udp_packets_bad_checksum) < 2) {
+ note ("%d bad udp checksums in %d packets",
+ udp_packets_bad_checksum, udp_packets_seen);
+ udp_packets_seen = udp_packets_bad_checksum = 0;
+ }
return -1;
}
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/common/tables.c
--- a/usr.sbin/dhcp/common/tables.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/common/tables.c Mon Apr 26 15:43:06 1999 +0000
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: tables.c,v 1.1.1.3 1999/02/18 21:48:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tables.c,v 1.1.1.4 1999/04/26 15:43:08 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -130,20 +130,20 @@
{ "dhcp-client-identifier", "X", &dhcp_universe, 61 },
{ "option-62", "X", &dhcp_universe, 62 },
{ "option-63", "X", &dhcp_universe, 63 },
- { "option-64", "X", &dhcp_universe, 64 },
- { "option-65", "X", &dhcp_universe, 65 },
- { "option-66", "X", &dhcp_universe, 66 },
- { "option-67", "X", &dhcp_universe, 67 },
- { "option-68", "X", &dhcp_universe, 68 },
- { "option-69", "X", &dhcp_universe, 69 },
- { "option-70", "X", &dhcp_universe, 70 },
- { "option-71", "X", &dhcp_universe, 71 },
- { "option-72", "X", &dhcp_universe, 72 },
- { "option-73", "X", &dhcp_universe, 73 },
- { "option-74", "X", &dhcp_universe, 74 },
- { "option-75", "X", &dhcp_universe, 75 },
- { "option-76", "X", &dhcp_universe, 76 },
- { "dhcp-user-class-identifier", "t", &dhcp_universe, 77 },
+ { "nisplus-domain", "t", &dhcp_universe, 64 },
+ { "nisplus-servers", "IA", &dhcp_universe, 65 },
+ { "tftp-server-name", "t", &dhcp_universe, 66 },
+ { "bootfile-name", "t", &dhcp_universe, 67 },
+ { "mobile-ip-home-agent", "IA", &dhcp_universe, 68 },
+ { "smtp-server", "IA", &dhcp_universe, 69 },
+ { "pop-server", "IA", &dhcp_universe, 70 },
+ { "nntp-server", "IA", &dhcp_universe, 71 },
+ { "www-server", "IA", &dhcp_universe, 72 },
+ { "finger-server", "IA", &dhcp_universe, 73 },
+ { "irc-server", "IA", &dhcp_universe, 74 },
+ { "streettalk-server", "IA", &dhcp_universe, 75 },
+ { "streettalk-directory-assistance-server", "IA", &dhcp_universe, 76 },
+ { "user-class", "t", &dhcp_universe, 77 },
{ "option-78", "X", &dhcp_universe, 78 },
{ "option-79", "X", &dhcp_universe, 79 },
{ "option-80", "X", &dhcp_universe, 80 },
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/includes/osdep.h
--- a/usr.sbin/dhcp/includes/osdep.h Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/includes/osdep.h Mon Apr 26 15:43:06 1999 +0000
@@ -119,10 +119,10 @@
# include "cf/cygwin32.h"
#endif
-#ifdef NeXT
-# ifdef __APPLE__
-# include "cf/rhapsody.h"
-# else
+#ifdef __APPLE__
+# include "cf/rhapsody.h"
+#else
+# if defined (NeXT)
# include "cf/nextstep.h"
# endif
#endif
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/relay/dhcrelay.c
--- a/usr.sbin/dhcp/relay/dhcrelay.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/relay/dhcrelay.c Mon Apr 26 15:43:06 1999 +0000
@@ -42,7 +42,7 @@
#ifndef lint
static char ocopyright [] =
-"$Id: dhcrelay.c,v 1.1.1.13 1999/04/09 17:52:09 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcrelay.c,v 1.1.1.14 1999/04/26 15:43:10 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -76,7 +76,7 @@
static char copyright [] =
"Copyright 1997, 1998, 1999 The Internet Software Consortium.";
static char arr [] = "All rights reserved.";
-static char message [] = "Internet Software Consortium DHCP Relay Agent V2.0b1pl25";
+static char message [] = "Internet Software Consortium DHCP Relay Agent V2.0b1pl27";
static char contrib [] = "Please contribute if you find this software useful.";
static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html";
diff -r 3420f517f0b2 -r a8538494052f usr.sbin/dhcp/server/db.c
--- a/usr.sbin/dhcp/server/db.c Mon Apr 26 14:48:57 1999 +0000
+++ b/usr.sbin/dhcp/server/db.c Mon Apr 26 15:43:06 1999 +0000
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: db.c,v 1.1.1.7 1999/02/18 21:48:54 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: db.c,v 1.1.1.8 1999/04/26 15:43:11 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -231,6 +231,15 @@
error ("Can't fdopen new lease file!");
}
+ /* Write an introduction so people don't complain about time
+ being off. */
+ fprintf (db_file, "# All times in this file are in UTC (GMT), not %s",
+ "your local timezone. This is\n");
+ fprintf (db_file, "# not a bug, so please don't ask about it. %s",
Home |
Main Index |
Thread Index |
Old Index