mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-28 20:43:54 +08:00
Minimum message size is now 300 bytes for crappy DHCP servers :/
This commit is contained in:
parent
378dcbd5d5
commit
750bc1d4f8
@ -1,3 +1,4 @@
|
||||
Minimum message size is now 300 bytes for crappy DHCP servers :/
|
||||
Compile ok on OpenBSD (thanks to icezimm and reb in #gentoo-bsd for testing)
|
||||
We check gcc supports -Wextra and friends before using them.
|
||||
We now restore the starting MTU value when we exit OR we don't receive a
|
||||
|
8
dhcp.c
8
dhcp.c
@ -38,8 +38,6 @@
|
||||
#include "logger.h"
|
||||
#include "socket.h"
|
||||
|
||||
#define BROADCAST_FLAG 0x8000
|
||||
|
||||
static const char *dhcp_message[] = {
|
||||
[DHCP_DISCOVER] = "DHCP_DISCOVER",
|
||||
[DHCP_OFFER] = "DHCP_OFFER",
|
||||
@ -248,7 +246,13 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
|
||||
|
||||
*p++ = DHCP_END;
|
||||
|
||||
#ifdef DHCP_MESSAGE_LENTH_MIN
|
||||
while (p - m < DHCP_MESSAGE_LENTH_MIN)
|
||||
*p++ = DHCP_PAD;
|
||||
#endif
|
||||
|
||||
message_length = p - m;
|
||||
logger (LOG_DEBUG, "xx %d\n", message_length);
|
||||
|
||||
memset (&packet, 0, sizeof (struct udp_dhcp_packet));
|
||||
make_dhcp_packet (&packet, (unsigned char *) &message, message_length,
|
||||
|
8
dhcp.h
8
dhcp.h
@ -31,6 +31,7 @@
|
||||
#include "dhcpcd.h"
|
||||
#include "interface.h"
|
||||
|
||||
|
||||
/* Max MTU - defines dhcp option length */
|
||||
#define MTU_MAX 1500
|
||||
#define MTU_MIN 576
|
||||
@ -40,6 +41,7 @@
|
||||
#define DHCP_CLIENT_PORT 68
|
||||
|
||||
#define MAGIC_COOKIE 0x63825363
|
||||
#define BROADCAST_FLAG 0x8000
|
||||
|
||||
/* DHCP message OP code */
|
||||
#define DHCP_BOOTREQUEST 1
|
||||
@ -55,7 +57,6 @@
|
||||
#define DHCP_RELEASE 7
|
||||
#define DHCP_INFORM 8
|
||||
|
||||
|
||||
/* DHCP options */
|
||||
enum DHCP_OPTIONS
|
||||
{
|
||||
@ -152,6 +153,8 @@ typedef struct dhcp_t
|
||||
char *rootpath;
|
||||
} dhcp_t;
|
||||
|
||||
|
||||
|
||||
/* Sizes for DHCP options */
|
||||
#define DHCP_CHADDR_LEN 16
|
||||
#define SERVERNAME_LEN 64
|
||||
@ -164,6 +167,9 @@ typedef struct dhcp_t
|
||||
#define DHCP_OPTION_LEN (MTU_MAX - DHCP_FIXED_LEN - DHCP_UDP_LEN \
|
||||
- DHCP_RESERVE_LEN)
|
||||
|
||||
/* Some crappy DHCP servers require the BOOTP minimum length */
|
||||
#define DHCP_MESSAGE_LENTH_MIN 300
|
||||
|
||||
typedef struct dhcpmessage_t
|
||||
{
|
||||
unsigned char op; /* message type */
|
||||
|
Loading…
Reference in New Issue
Block a user