summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-02-14 11:58:41 +0100
committerTom Gundersen <teg@jklm.no>2014-02-15 12:14:45 +0100
commit0bfedf143c72005cb540ddcaf9a8630844e381f8 (patch)
treed6118ab5a5bb283d155c24185252f2ace8aa0a6d /src/libsystemd-dhcp
parente5002702716b047c3d5515aaeecc5b829db02aa4 (diff)
sd-dhcp: minimum options size is part of the protocol
Diffstat (limited to 'src/libsystemd-dhcp')
-rw-r--r--src/libsystemd-dhcp/dhcp-protocol.h1
-rw-r--r--src/libsystemd-dhcp/sd-dhcp-client.c12
2 files changed, 6 insertions, 7 deletions
diff --git a/src/libsystemd-dhcp/dhcp-protocol.h b/src/libsystemd-dhcp/dhcp-protocol.h
index abdfe8d54b..81d36cef27 100644
--- a/src/libsystemd-dhcp/dhcp-protocol.h
+++ b/src/libsystemd-dhcp/dhcp-protocol.h
@@ -58,6 +58,7 @@ typedef struct DHCPPacket DHCPPacket;
#define DHCP_IP_SIZE (int32_t)(sizeof(struct iphdr))
#define DHCP_IP_UDP_SIZE (int32_t)(sizeof(struct udphdr) + DHCP_IP_SIZE)
#define DHCP_MESSAGE_SIZE (int32_t)(sizeof(DHCPMessage))
+#define DHCP_MIN_OPTIONS_SIZE 312
enum {
DHCP_PORT_SERVER = 67,
diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c
index 39c2eebffc..bff35885f6 100644
--- a/src/libsystemd-dhcp/sd-dhcp-client.c
+++ b/src/libsystemd-dhcp/sd-dhcp-client.c
@@ -32,8 +32,6 @@
#include "dhcp-internal.h"
#include "sd-dhcp-client.h"
-#define DHCP_CLIENT_MIN_OPTIONS_SIZE 312
-
struct sd_dhcp_client {
DHCPState state;
sd_event *event;
@@ -237,7 +235,7 @@ static int client_message_init(sd_dhcp_client *client, DHCPMessage *message,
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);
+ DHCP_MIN_OPTIONS_SIZE);
r = dhcp_option_append(opt, optlen,
DHCP_OPTION_MAXIMUM_MESSAGE_SIZE,
2, &max_size);
@@ -254,7 +252,7 @@ static int client_send_discover(sd_dhcp_client *client, uint16_t secs) {
size_t optlen, len;
uint8_t *opt;
- optlen = DHCP_CLIENT_MIN_OPTIONS_SIZE;
+ optlen = DHCP_MIN_OPTIONS_SIZE;
len = sizeof(DHCPPacket) + optlen;
discover = malloc0(len);
@@ -293,7 +291,7 @@ static int client_send_request(sd_dhcp_client *client, uint16_t secs) {
int err;
uint8_t *opt;
- optlen = DHCP_CLIENT_MIN_OPTIONS_SIZE;
+ optlen = DHCP_MIN_OPTIONS_SIZE;
len = DHCP_MESSAGE_SIZE + optlen;
request = malloc0(len);
@@ -801,7 +799,7 @@ error:
static int client_receive_message_raw(sd_event_source *s, int fd,
uint32_t revents, void *userdata) {
sd_dhcp_client *client = userdata;
- uint8_t buf[sizeof(DHCPMessage) + DHCP_CLIENT_MIN_OPTIONS_SIZE];
+ uint8_t buf[sizeof(DHCPMessage) + DHCP_MIN_OPTIONS_SIZE];
int buflen = sizeof(buf);
int len, r = 0;
usec_t time_now;
@@ -825,7 +823,7 @@ static int client_receive_message_raw(sd_event_source *s, int fd,
static int client_receive_message_udp(sd_event_source *s, int fd,
uint32_t revents, void *userdata) {
sd_dhcp_client *client = userdata;
- uint8_t buf[sizeof(DHCPPacket) + DHCP_CLIENT_MIN_OPTIONS_SIZE];
+ uint8_t buf[sizeof(DHCPPacket) + DHCP_MIN_OPTIONS_SIZE];
int buflen = sizeof(buf);
int len, r = 0;
DHCPPacket *packet;