mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-22 18:07:25 +00:00
Read DHCP packet into aligned buffer and pass it as a struct pointer instead of a character buffer.
This commit is contained in:
parent
52cdb300e7
commit
ca0e3669b8
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: dispatch.c,v 1.49 1998/04/09 04:30:00 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: dispatch.c,v 1.50 1998/06/25 02:55:16 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@ -54,7 +54,7 @@ struct timeout *timeouts;
|
|||||||
static struct timeout *free_timeouts;
|
static struct timeout *free_timeouts;
|
||||||
static int interfaces_invalidated;
|
static int interfaces_invalidated;
|
||||||
void (*bootp_packet_handler) PROTO ((struct interface_info *,
|
void (*bootp_packet_handler) PROTO ((struct interface_info *,
|
||||||
unsigned char *, int, unsigned int,
|
struct dhcp_packet *, int, unsigned int,
|
||||||
struct iaddr, struct hardware *));
|
struct iaddr, struct hardware *));
|
||||||
|
|
||||||
static void got_one PROTO ((struct protocol *));
|
static void got_one PROTO ((struct protocol *));
|
||||||
@ -577,13 +577,16 @@ static void got_one (l)
|
|||||||
struct hardware hfrom;
|
struct hardware hfrom;
|
||||||
struct iaddr ifrom;
|
struct iaddr ifrom;
|
||||||
int result;
|
int result;
|
||||||
static unsigned char packbuf [4095]; /* Packet input buffer.
|
union {
|
||||||
Must be as large as largest
|
unsigned char packbuf [4095]; /* Packet input buffer.
|
||||||
possible MTU. */
|
Must be as large as largest
|
||||||
|
possible MTU. */
|
||||||
|
struct dhcp_packet packet;
|
||||||
|
} u;
|
||||||
struct interface_info *ip = l -> local;
|
struct interface_info *ip = l -> local;
|
||||||
|
|
||||||
if ((result = receive_packet (ip, packbuf, sizeof packbuf,
|
if ((result =
|
||||||
&from, &hfrom)) < 0) {
|
receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) {
|
||||||
warn ("receive_packet failed on %s: %m", ip -> name);
|
warn ("receive_packet failed on %s: %m", ip -> name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -594,7 +597,7 @@ static void got_one (l)
|
|||||||
ifrom.len = 4;
|
ifrom.len = 4;
|
||||||
memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len);
|
memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len);
|
||||||
|
|
||||||
(*bootp_packet_handler) (ip, packbuf, result,
|
(*bootp_packet_handler) (ip, &u.packet, result,
|
||||||
from.sin_port, ifrom, &hfrom);
|
from.sin_port, ifrom, &hfrom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user