+ size = sizeof(DHCPPacket) + 4;
+ assert(len > size);
+
+ discover = memdup(packet, len);
+
+ assert(memcmp(discover->dhcp.chaddr,
+ &mac_addr.ether_addr_octet, 6) == 0);
+ assert(discover->ip.ttl == IPDEFTTL);
+ assert(discover->ip.protocol == IPPROTO_UDP);
+ assert(discover->ip.saddr == INADDR_ANY);
+ assert(discover->ip.daddr == INADDR_BROADCAST);
+ assert(discover->udp.source == be16toh(DHCP_PORT_CLIENT));
+ assert(discover->udp.dest == be16toh(DHCP_PORT_SERVER));
+
+ ip_check = discover->ip.check;
+
+ discover->ip.ttl = 0;
+ discover->ip.check = discover->udp.len;
+
+ udp_check = ~client_checksum(&discover->ip.ttl, len - 8);
+ assert(udp_check == 0xffff);
+
+ discover->ip.ttl = IPDEFTTL;
+ discover->ip.check = ip_check;
+
+ ip_check = ~client_checksum(&discover->ip, sizeof(discover->ip));
+ assert(ip_check == 0xffff);
+
+ size = len - sizeof(struct iphdr) - sizeof(struct udphdr);
+
+ res = dhcp_option_parse(&discover->dhcp, size, check_options, NULL);
+ if (res < 0)
+ return res;
+
+ return 575;
+}
+
+int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
+{
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_fd) < 0)
+ return -errno;
+
+ return test_fd[0];
+}
+
+int dhcp_network_bind_udp_socket(int index, be32_t client_address)
+{
+ return 0;
+}
+
+int dhcp_network_send_udp_socket(int s, be32_t server_address,
+ const void *packet, size_t len)
+{
+ return 0;
+}
+
+static void test_discover_message(sd_event *e)
+{
+ sd_dhcp_client *client;
+ int res;
+
+ client = sd_dhcp_client_new(e);
+ assert(client);
+
+ assert(sd_dhcp_client_set_index(client, 42) >= 0);
+ assert(sd_dhcp_client_set_mac(client, &mac_addr) >= 0);
+
+ assert(sd_dhcp_client_set_request_option(client, 248) >= 0);
+
+ res = sd_dhcp_client_start(client);
+
+ assert(res == 0 || res == -EINPROGRESS);
+
+ close(test_fd[0]);
+ close(test_fd[1]);