d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog/***
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog This file is part of systemd.
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog Copyright (C) 2014 Axis Communications AB. All rights reserved.
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog systemd is free software; you can redistribute it and/or modify it
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog under the terms of the GNU Lesser General Public License as published by
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog the Free Software Foundation; either version 2.1 of the License, or
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog (at your option) any later version.
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog systemd is distributed in the hope that it will be useful, but
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog WITHOUT ANY WARRANTY; without even the implied warranty of
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog Lesser General Public License for more details.
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog You should have received a copy of the GNU Lesser General Public License
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog along with systemd; If not, see <http://www.gnu.org/licenses/>.
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog***/
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include <assert.h>
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include <errno.h>
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include <stdio.h>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include <stdlib.h>
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include <sys/socket.h>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include <sys/types.h>
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include <unistd.h>
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog#include "sd-ipv4ll.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen#include "arp-util.h"
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#include "fd-util.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "socket-util.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "util.h"
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic bool verbose = false;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic bool extended = false;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic int test_fd[2];
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic int basic_request_handler_bind = 0;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic int basic_request_handler_stop = 0;
89ca10c6a61309d84d54c5dc5a295387ce39e610Lennart Poetteringstatic void* basic_request_handler_userdata = (void*)0xCABCAB;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic void basic_request_handler(sd_ipv4ll *ll, int event, void *userdata) {
89ca10c6a61309d84d54c5dc5a295387ce39e610Lennart Poettering assert_se(userdata == basic_request_handler_userdata);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog switch(event) {
be19c5b5e0c0f78b8429b126936fa15856550a23David Herrmann case SD_IPV4LL_EVENT_STOP:
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog basic_request_handler_stop = 1;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog break;
be19c5b5e0c0f78b8429b126936fa15856550a23David Herrmann case SD_IPV4LL_EVENT_BIND:
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog basic_request_handler_bind = 1;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog break;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog default:
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog break;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog }
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenstatic int arp_network_send_raw_socket(int fd, int ifindex,
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen const struct ether_arp *arp) {
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(arp);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert_se(ifindex > 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(fd >= 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog if (send(fd, arp, sizeof(struct ether_arp), 0) < 0)
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog return -errno;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog return 0;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenint arp_send_probe(int fd, int ifindex,
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen be32_t pa, const struct ether_addr *ha) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen struct ether_arp ea = {};
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(fd >= 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(ifindex > 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(pa != 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(ha);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return arp_network_send_raw_socket(fd, ifindex, &ea);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenint arp_send_announcement(int fd, int ifindex,
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen be32_t pa, const struct ether_addr *ha) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen struct ether_arp ea = {};
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(fd >= 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(ifindex > 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(pa != 0);
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen assert(ha);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return arp_network_send_raw_socket(fd, ifindex, &ea);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersenint arp_network_bind_raw_socket(int index, be32_t address, const struct ether_addr *eth_mac) {
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return -errno;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
996d16975b4d802335188a3be2bbc3635c1287f3Tom Gundersen return test_fd[0];
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic void test_public_api_setters(sd_event *e) {
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen struct in_addr address = {};
5625be76c755c99f8b41d7fe84156ebc732b454cRonny Chevalier unsigned seed = 0;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_ipv4ll *ll;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog struct ether_addr mac_addr = {
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}};
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog if (verbose)
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog printf("* %s\n", __FUNCTION__);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_new(&ll) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(ll);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_attach_event(NULL, NULL, 0) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_attach_event(ll, e, 0) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_attach_event(ll, e, 0) == -EBUSY);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_callback(NULL, NULL, NULL) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_callback(ll, NULL, NULL) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen address.s_addr |= htobe32(169U << 24 | 254U << 16);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen address.s_addr |= htobe32(0x00FF);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen address.s_addr |= htobe32(0xF000);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen assert_se(sd_ipv4ll_set_address(ll, &address) == 0);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen address.s_addr |= htobe32(0x0F00);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
129dc1b489d924d28956b09a06f03d7607beb8adTom Gundersen
5625be76c755c99f8b41d7fe84156ebc732b454cRonny Chevalier assert_se(sd_ipv4ll_set_address_seed(NULL, seed) == -EINVAL);
5625be76c755c99f8b41d7fe84156ebc732b454cRonny Chevalier assert_se(sd_ipv4ll_set_address_seed(ll, seed) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_mac(NULL, NULL) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_mac(ll, NULL) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_mac(ll, &mac_addr) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(NULL, -1) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(ll, -1) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(ll, -99) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(ll, 1) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(ll, 99) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_ref(ll) == ll);
b45e4eb679ad0c9a77c4fe6e404c8842d4097fdbTom Gundersen assert_se(sd_ipv4ll_unref(ll) == NULL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog /* Cleanup */
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_unref(ll) == NULL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogstatic void test_basic_request(sd_event *e) {
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_ipv4ll *ll;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog struct ether_arp arp;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog struct ether_addr mac_addr = {
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}};
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog if (verbose)
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog printf("* %s\n", __FUNCTION__);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_new(&ll) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_attach_event(ll, e, 0) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_mac(ll, &mac_addr) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_callback(ll, basic_request_handler,
89ca10c6a61309d84d54c5dc5a295387ce39e610Lennart Poettering basic_request_handler_userdata) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == -EINVAL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_set_index(ll, 1) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_event_run(e, (uint64_t) -1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_start(ll) == -EBUSY);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen assert_se(sd_ipv4ll_is_running(ll));
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog /* PROBE */
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_event_run(e, (uint64_t) -1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(read(test_fd[1], &arp, sizeof(struct ether_arp)) == sizeof(struct ether_arp));
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog if (extended) {
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog /* PROBE */
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_event_run(e, (uint64_t) -1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(read(test_fd[1], &arp, sizeof(struct ether_arp)) == sizeof(struct ether_arp));
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog /* PROBE */
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_event_run(e, (uint64_t) -1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(read(test_fd[1], &arp, sizeof(struct ether_arp)) == sizeof(struct ether_arp));
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_event_run(e, (uint64_t) -1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(basic_request_handler_bind == 1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog }
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog sd_ipv4ll_stop(ll);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(basic_request_handler_stop == 1);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog /* Cleanup */
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_ipv4ll_unref(ll) == NULL);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog safe_close(test_fd[1]);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskogint main(int argc, char *argv[]) {
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering _cleanup_(sd_event_unrefp) sd_event *e = NULL;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen log_set_max_level(LOG_DEBUG);
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen log_parse_environment();
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen log_open();
e3dca0089b7b50e2ec21409d1292727921d06102Tom Gundersen
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog assert_se(sd_event_new(&e) >= 0);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog test_public_api_setters(e);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog test_basic_request(e);
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog return 0;
d9bf4f8c6c47b8620ffa1a056208eb15118b78d5Umut Tezduyar Lindskog}