test-pppoe.c revision 618234a5258768359cb1086b152c5f08aaf89754
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include "sd-event.h"
#include "sd-netlink.h"
#include "sd-pppoe.h"
#include "event-util.h"
#include "process-util.h"
#include "util.h"
static int pppoe_state = -1;
assert_se(e);
switch (event) {
case SD_PPPOE_EVENT_RUNNING:
log_info("running");
break;
case SD_PPPOE_EVENT_STOPPED:
log_info("stopped");
assert_se(sd_event_exit(e, 0) >= 0);
break;
default:
assert_not_reached("invalid pppoe event");
}
pppoe_state = event;
}
int client_ifindex;
assert_se(client_ifindex > 0);
log_info("starting PPPoE client, it will exit when the server times out and sends PADT");
assert_se(sd_event_loop(e) >= 0);
return EXIT_SUCCESS;
}
static int test_pppoe_server(sd_event *e) {
int r, client_ifindex, server_ifindex;
r = unshare(CLONE_NEWNET);
return EXIT_TEST_SKIP;
assert_se(r >= 0);
assert_se(sd_netlink_message_close_container(m) >= 0);
assert_se(sd_netlink_message_close_container(m) >= 0);
assert_se(sd_netlink_message_close_container(m) >= 0);
assert_se(client_ifindex > 0);
assert_se(server_ifindex > 0);
m = sd_netlink_message_unref(m);
m = sd_netlink_message_unref(m);
if (pid == 0) {
/* let the client send some discover messages before the server is started */
sleep(2);
/* TODO: manage pppoe-server-options */
"-I", "pppoe-server",
"-C", "Test-AC",
"-S", "Service-Default",
"-S", "Service-First-Auxiliary",
"-S", "Service-Second-Auxiliary",
NULL);
assert_not_reached("failed to execute pppoe-server. not installed?");
}
client_run("pppoe-client", e);
return EXIT_SUCCESS;
}
log_open();
assert_se(sd_event_new(&e) >= 0);
if (argc == 1) {
log_info("running PPPoE client against local server");
return test_pppoe_server(e);
} else if (argc == 2) {
} else {
log_error("This program takes one or no arguments.\n"
"\t %s [<ifname>]", program_invocation_short_name);
return EXIT_FAILURE;
}
}