summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-12-09 23:43:28 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-12 11:43:34 -0500
commit564ba3b0efbcaf8d5881dbfb80d3c0b174ccaba5 (patch)
treea9f327d881f32e503eea6d2f4992aab654e18179 /src/libsystemd-dhcp
parente2dfc79f0624dfbfa30156880b31b13510405f54 (diff)
dhcp: Add maximum message size option
Add maximum message size option to keep some DHCP server implementations from sending too big messages. See ConnMan commit 0c5c862749c05193cf4c513628328c6db02b5222.
Diffstat (limited to 'src/libsystemd-dhcp')
-rw-r--r--src/libsystemd-dhcp/dhcp-client.c12
-rw-r--r--src/libsystemd-dhcp/dhcp-protocol.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c
index 4980174e00..b1bdd38593 100644
--- a/src/libsystemd-dhcp/dhcp-client.c
+++ b/src/libsystemd-dhcp/dhcp-client.c
@@ -186,6 +186,7 @@ static int client_packet_init(sd_dhcp_client *client, uint8_t type,
uint8_t **opt, size_t *optlen)
{
int err;
+ be16_t max_size;
*opt = (uint8_t *)(message + 1);
@@ -229,6 +230,17 @@ static int client_packet_init(sd_dhcp_client *client, uint8_t type,
client->req_opts);
if (err < 0)
return err;
+
+ /* Some DHCP servers will send bigger DHCP packets than the
+ defined default size unless the Maximum Messge Size option
+ is explicitely set */
+ max_size = htobe16(DHCP_IP_UDP_SIZE + DHCP_MESSAGE_SIZE +
+ DHCP_CLIENT_MIN_OPTIONS_SIZE);
+ err = dhcp_option_append(opt, optlen,
+ DHCP_OPTION_MAXIMUM_MESSAGE_SIZE,
+ 2, &max_size);
+ if (err < 0)
+ return err;
}
return 0;
diff --git a/src/libsystemd-dhcp/dhcp-protocol.h b/src/libsystemd-dhcp/dhcp-protocol.h
index 95c4f4ea66..f5f490d8b9 100644
--- a/src/libsystemd-dhcp/dhcp-protocol.h
+++ b/src/libsystemd-dhcp/dhcp-protocol.h
@@ -111,6 +111,7 @@ enum {
DHCP_OPTION_MESSAGE_TYPE = 53,
DHCP_OPTION_SERVER_IDENTIFIER = 54,
DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
+ DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
DHCP_OPTION_CLIENT_IDENTIFIER = 61,
DHCP_OPTION_END = 255,
};