From 4671a004574bec2ae4ae776803f6f30b4d53c629 Mon Sep 17 00:00:00 2001 From: pelikan Date: Mon, 5 May 2014 18:30:44 +0000 Subject: [PATCH] Don't call the BOOTP handler indirectly. ok krw --- usr.sbin/dhcpd/dhcpd.c | 3 +-- usr.sbin/dhcpd/dhcpd.h | 4 +--- usr.sbin/dhcpd/dispatch.c | 16 +++++----------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c index 00134b8a943..8d1cb682a1b 100644 --- a/usr.sbin/dhcpd/dhcpd.c +++ b/usr.sbin/dhcpd/dhcpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.c,v 1.42 2014/05/05 18:27:57 pelikan Exp $ */ +/* $OpenBSD: dhcpd.c,v 1.43 2014/05/05 18:30:44 pelikan Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -220,7 +220,6 @@ main(int argc, char *argv[]) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) error("can't drop privileges: %m"); - bootp_packet_handler = do_packet; add_timeout(cur_time + 5, periodic_scan, NULL); dispatch(); diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h index be619607683..d19a0d6d97b 100644 --- a/usr.sbin/dhcpd/dhcpd.h +++ b/usr.sbin/dhcpd/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.48 2014/05/05 18:27:57 pelikan Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.49 2014/05/05 18:30:44 pelikan Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -625,8 +625,6 @@ ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, /* dispatch.c */ extern struct interface_info *interfaces; extern struct protocol *protocols; -extern void (*bootp_packet_handler)(struct interface_info *, - struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *); extern struct dhcpd_timeout *timeouts; void discover_interfaces(int *); void dispatch(void); diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index 0e78bc96200..776506d55b4 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.32 2013/10/18 15:19:39 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.33 2014/05/05 18:30:44 pelikan Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -52,8 +52,6 @@ struct protocol *protocols; struct dhcpd_timeout *timeouts; static struct dhcpd_timeout *free_timeouts; static int interfaces_invalidated; -void (*bootp_packet_handler)(struct interface_info *, - struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *); static int interface_status(struct interface_info *ifinfo); int get_rdomain(char *); @@ -277,8 +275,7 @@ discover_interfaces(int *rdomain) /* * Wait for packets to come in using poll(). When a packet comes in, * call receive_packet to receive the packet and possibly strip hardware - * addressing information from it, and then call through the - * bootp_packet_handler hook to try to do something with it. + * addressing information from it, and then process it in do_packet. */ void dispatch(void) @@ -417,13 +414,10 @@ got_one(struct protocol *l) if (result == 0) return; - if (bootp_packet_handler) { - ifrom.len = 4; - memcpy(ifrom.iabuf, &from.sin_addr, ifrom.len); + ifrom.len = 4; + memcpy(ifrom.iabuf, &from.sin_addr, ifrom.len); - (*bootp_packet_handler)(ip, &u.packet, result, - from.sin_port, ifrom, &hfrom); - } + do_packet(ip, &u.packet, result, from.sin_port, ifrom, &hfrom); } int -- 2.20.1