Ultrix PacketFilter interface code. */
/*
- * Copyright (c) 1996-2000 Internet Software Consortium.
- * All rights reserved.
+ * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996-2003 by Internet Software Consortium
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
- * 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.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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.
+ * Internet Systems Consortium, Inc.
+ * PO Box 360
+ * Newmarket, NH 03857 USA
+ * <info@isc.org>
+ * https://www.isc.org/
*
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
- * To learn more about the Internet Software Consortium, see
- * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
- * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
- * ``http://www.nominum.com''.
*/
-#ifndef lint
-static char copyright[] =
-"$Id: upf.c,v 1.21 2000/09/01 23:03:39 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
#include "dhcpd.h"
#if defined (USE_UPF_SEND) || defined (USE_UPF_RECEIVE)
#include <sys/ioctl.h>
/* Open a UPF device */
for (b = 0; 1; b++) {
-#ifndef NO_SNPRINTF
- snprintf(filename, sizeof(filename), "/dev/pf/pfilt%d", b);
-#else
+ /* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
sprintf(filename, "/dev/pf/pfilt%d", b);
-#endif
+
sock = open (filename, O_RDWR, 0);
if (sock < 0) {
if (errno == EBUSY) {
info -> name);
/* We only know how to do ethernet. */
- if (param.end_dev_type != ENDT_10MB)
+ if (param.end_dev_type != ENDT_10MB)
log_fatal ("Invalid device type on network interface %s: %d",
info -> name, param.end_dev_type);
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the UPF program! XXX */
+#if defined(RELAY_PORT)
+#error "Relay port is not yet supported for UPF"
+#endif
void if_register_receive (info)
struct interface_info *info;
return send_fallback (interface, packet, raw,
len, from, to, hto);
+ if (hto == NULL && interface->anycast_mac_addr.hlen)
+ hto = &interface->anycast_mac_addr;
+
/* Assemble the headers... */
assemble_hw_header (interface, (unsigned char *)hw, &hbufp, hto);
assemble_udp_ip_header (interface,
int offset = 0;
unsigned char ibuf [1500 + sizeof (struct enstamp)];
int bufix = 0;
+ unsigned paylen;
length = read (interface -> rfdesc, ibuf, sizeof ibuf);
if (length <= 0)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
- from, (unsigned char *)0, length);
+ from, length, &paylen, 1);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
bufix += offset;
length -= offset;
+ if (length < paylen)
+ log_fatal("Internal inconsistency at %s:%d.", MDL);
+
/* Copy out the data in the packet... */
- memcpy (buf, &ibuf [bufix], length);
- return length;
+ memcpy (buf, &ibuf[bufix], paylen);
+ return paylen;
}
int can_unicast_without_arp (ip)