***/
#include <errno.h>
+#include <net/if.h>
+#include <net/if_arp.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
-#include <net/if.h>
#include "sd-dhcp-client.h"
#include "sd-event.h"
}
int dhcp_network_bind_raw_socket(
- int index,
+ int ifindex,
union sockaddr_union *link,
uint32_t id,
const uint8_t *addr, size_t addr_len,
return test_fd[0];
}
-int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
+int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int ip_service_type) {
int fd;
fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-static void test_addr_acq_acquired(sd_dhcp_client *client, int event,
+static int test_addr_acq_acquired(sd_dhcp_client *client, int event,
void *userdata) {
sd_event *e = userdata;
sd_dhcp_lease *lease;
const struct in_addr *addrs;
assert_se(client);
- assert_se(event == SD_DHCP_CLIENT_EVENT_IP_ACQUIRE);
+ assert_se(IN_SET(event, SD_DHCP_CLIENT_EVENT_IP_ACQUIRE, SD_DHCP_CLIENT_EVENT_SELECTING));
assert_se(sd_dhcp_client_get_lease(client, &lease) >= 0);
assert_se(lease);
printf(" DHCP address acquired\n");
sd_event_exit(e, 0);
+
+ return 0;
}
static int test_addr_acq_recv_request(size_t size, DHCPMessage *request) {
}
static void test_addr_acq(sd_event *e) {
- usec_t time_now = now(clock_boottime_or_monotonic());
sd_dhcp_client *client;
int res, r;
callback_recv = test_addr_acq_recv_discover;
- assert_se(sd_event_add_time(e, &test_hangcheck,
- clock_boottime_or_monotonic(),
- time_now + 2 * USEC_PER_SEC, 0,
- test_dhcp_hangcheck, NULL) >= 0);
+ assert_se(sd_event_add_time_relative(
+ e, &test_hangcheck,
+ clock_boottime_or_monotonic(),
+ 2 * USEC_PER_SEC, 0,
+ test_dhcp_hangcheck, NULL) >= 0);
res = sd_dhcp_client_start(client);
assert_se(IN_SET(res, 0, -EINPROGRESS));