int sd_ipv4acd_start(sd_ipv4acd *acd) { int r; assert_return(acd, -EINVAL); assert_return(acd->event, -EINVAL); assert_return(acd->ifindex > 0, -EINVAL); assert_return(acd->address != 0, -EINVAL); assert_return(!ether_addr_is_null(&acd->mac_addr), -EINVAL); assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); r = arp_network_bind_raw_socket(acd->ifindex, acd->address, &acd->mac_addr); if (r < 0) return r; safe_close(acd->fd); acd->fd = r; acd->defend_window = 0; acd->n_conflict = 0; r = sd_event_add_io(acd->event, &acd->receive_message_event_source, acd->fd, EPOLLIN, ipv4acd_on_packet, acd); if (r < 0) goto fail; r = sd_event_source_set_priority(acd->receive_message_event_source, acd->event_priority); if (r < 0) goto fail; (void) sd_event_source_set_description(acd->receive_message_event_source, "ipv4acd-receive-message"); r = ipv4acd_set_next_wakeup(acd, 0, 0); if (r < 0) goto fail; ipv4acd_set_state(acd, IPV4ACD_STATE_STARTED, true); return 0; fail: ipv4acd_reset(acd); return r; }
static bool lldp_keep_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) { assert(lldp); assert(n); /* Don't keep data with a zero TTL */ if (n->ttl <= 0) return false; /* Filter out data from the filter address */ if (!ether_addr_is_null(&lldp->filter_address) && ether_addr_equal(&lldp->filter_address, &n->source_address)) return false; /* Only add if the neighbor has a capability we are interested in. Note that we also store all neighbors with * no caps field set. */ if (n->has_capabilities && (n->enabled_capabilities & lldp->capability_mask) == 0) return false; /* Keep everything else */ return true; }