summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2014-03-20 10:31:49 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2014-03-20 10:56:29 +0200
commitd790d3f17325df9004b1a6cc4f5a107d5eeec7d8 (patch)
tree8b1589270095320768442ae21b924d030b063ed3 /src
parent9d7bf1d58c2ce7f383f256a5beb1f5fc4ee843f5 (diff)
libsystemd-dhcp: Update client test case for client id and end option
Check that the client identifier is formatted as suggested in the RFC and that the messages sent ends with an end option.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/test-dhcp-client.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 1eb4648012..ca44cfbdc5 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -128,6 +128,17 @@ static void test_checksum(void)
static int check_options(uint8_t code, uint8_t len, const uint8_t *option,
void *user_data)
{
+ switch(code) {
+ case DHCP_OPTION_CLIENT_IDENTIFIER:
+ assert_se(len == 7);
+ assert_se(option[0] == 0x01);
+ assert_se(memcmp(&option[1], &mac_addr, ETH_ALEN) == 0);
+ break;
+
+ default:
+ break;
+ }
+
return 0;
}
@@ -370,12 +381,15 @@ static void test_addr_acq_acquired(sd_dhcp_client *client, int event,
static int test_addr_acq_recv_request(size_t size, DHCPMessage *request)
{
uint16_t udp_check = 0;
+ uint8_t *msg_bytes = (uint8_t *)request;
int res;
res = dhcp_option_parse(request, size, check_options, NULL);
assert_se(res == DHCP_REQUEST);
assert_se(xid == request->xid);
+ assert_se(msg_bytes[size - 1] == DHCP_OPTION_END);
+
if (verbose)
printf(" recv DHCP Request 0x%08x\n", be32toh(xid));
@@ -399,11 +413,14 @@ static int test_addr_acq_recv_request(size_t size, DHCPMessage *request)
static int test_addr_acq_recv_discover(size_t size, DHCPMessage *discover)
{
uint16_t udp_check = 0;
+ uint8_t *msg_bytes = (uint8_t *)discover;
int res;
res = dhcp_option_parse(discover, size, check_options, NULL);
assert_se(res == DHCP_DISCOVER);
+ assert_se(msg_bytes[size - 1] == DHCP_OPTION_END);
+
xid = discover->xid;
if (verbose)