int sd_ipv4ll_new(sd_ipv4ll **ret) { _cleanup_(sd_ipv4ll_unrefp) sd_ipv4ll *ll = NULL; int r; assert_return(ret, -EINVAL); ll = new0(sd_ipv4ll, 1); if (!ll) return -ENOMEM; ll->n_ref = 1; r = sd_ipv4acd_new(&ll->acd); if (r < 0) return r; r = sd_ipv4acd_set_callback(ll->acd, ipv4ll_on_acd, ll); if (r < 0) return r; *ret = ll; ll = NULL; return 0; }
static int client_run(int ifindex, const struct in_addr *pa, const struct ether_addr *ha, sd_event *e) { sd_ipv4acd *acd; assert_se(sd_ipv4acd_new(&acd) >= 0); assert_se(sd_ipv4acd_attach_event(acd, e, 0) >= 0); assert_se(sd_ipv4acd_set_index(acd, ifindex) >= 0); assert_se(sd_ipv4acd_set_mac(acd, ha) >= 0); assert_se(sd_ipv4acd_set_address(acd, pa) >= 0); assert_se(sd_ipv4acd_set_callback(acd, acd_handler, NULL) >= 0); log_info("starting IPv4ACD client"); assert_se(sd_ipv4acd_start(acd) >= 0); assert_se(sd_event_loop(e) >= 0); assert_se(!sd_ipv4acd_unref(acd)); return EXIT_SUCCESS; }