summaryrefslogtreecommitdiff
path: root/src/dumm/testing.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2008-10-29 11:11:01 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2008-10-29 11:11:01 +0000
commit8b80ab5a6950ce6515f477624794defd7531642a (patch)
treeaa8303f3806c5615fbeafc4dc82febe3cd7c24dc /src/dumm/testing.c
parentdb67c87db3c9089ea8d2e14f617bf3d9e2af261f (diff)
downloadvyos-strongswan-8b80ab5a6950ce6515f477624794defd7531642a.tar.gz
vyos-strongswan-8b80ab5a6950ce6515f477624794defd7531642a.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.2.8)
Diffstat (limited to 'src/dumm/testing.c')
-rw-r--r--src/dumm/testing.c171
1 files changed, 0 insertions, 171 deletions
diff --git a/src/dumm/testing.c b/src/dumm/testing.c
deleted file mode 100644
index c0d23296b..000000000
--- a/src/dumm/testing.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program 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 General Public License
- * for more details.
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <library.h>
-#include <dumm.h>
-
-/**
- * number of running guests
- */
-static int running = 0;
-
-/**
- * Guest invocation callback
- */
-static pid_t invoke(void *vte, guest_t *guest,
- char *args[], int argc)
-{
- pid_t pid;
-
- args[argc] = "con0=xterm";
-
- pid = fork();
- switch (pid)
- {
- case 0: /* child */
- dup2(open("/dev/null", 0), 1);
- dup2(open("/dev/null", 0), 2);
- execvp(args[0], args);
- exit(-1);
- case -1:
- fprintf(stderr, "starting guest '%s' failed\n", guest->get_name(guest));
- return 0;
- default:
- printf("started guest '%s', pid: %d\n", guest->get_name(guest), pid);
- running++;
- return pid;
- }
-}
-
-/**
- * main routine, parses args and reads from console
- */
-int main(int argc, char *argv[])
-{
- dumm_t *dumm;
- enumerator_t *enumerator;
- guest_t *guest;
- bridge_t *switch0, *switch1, *switch2;
- iface_t *iface;
- sigset_t set;
- siginfo_t info;
-
- library_init(NULL);
-
- dumm = dumm_create(NULL);
-
- switch0 = dumm->create_bridge(dumm, "switch0");
- switch1 = dumm->create_bridge(dumm, "switch1");
- switch2 = dumm->create_bridge(dumm, "switch2");
-
- if (switch0 && switch1 && switch2)
- {
- enumerator = dumm->create_guest_enumerator(dumm);
- while (enumerator->enumerate(enumerator, &guest))
- {
- if (!guest->start(guest, invoke, NULL, NULL))
- {
- continue;
- }
- if (streq(guest->get_name(guest), "alice"))
- {
- iface = guest->create_iface(guest, "eth0");
- if (iface)
- {
- switch1->connect_iface(switch1, iface);
- }
- iface = guest->create_iface(guest, "eth1");
- if (iface)
- {
- switch0->connect_iface(switch0, iface);
- }
- }
- else if (streq(guest->get_name(guest), "moon") ||
- streq(guest->get_name(guest), "sun"))
- {
- iface = guest->create_iface(guest, "eth0");
- if (iface)
- {
- switch0->connect_iface(switch0, iface);
- }
- iface = guest->create_iface(guest, "eth1");
- if (iface)
- {
- switch1->connect_iface(switch1, iface);
- }
- }
- else if (streq(guest->get_name(guest), "bob"))
- {
- iface = guest->create_iface(guest, "eth0");
- if (iface)
- {
- switch2->connect_iface(switch2, iface);
- }
- }
- else if (streq(guest->get_name(guest), "venus"))
- {
- iface = guest->create_iface(guest, "eth0");
- if (iface)
- {
- switch1->connect_iface(switch1, iface);
- }
- }
- else if (streq(guest->get_name(guest), "carol") ||
- streq(guest->get_name(guest), "winnetou") ||
- streq(guest->get_name(guest), "dave"))
- {
- iface = guest->create_iface(guest, "eth0");
- if (iface)
- {
- switch0->connect_iface(switch0, iface);
- }
- }
- }
- enumerator->destroy(enumerator);
-
- sigemptyset(&set);
- sigaddset(&set, SIGINT);
- sigaddset(&set, SIGHUP);
- sigaddset(&set, SIGTERM);
- sigaddset(&set, SIGCHLD);
- sigprocmask(SIG_SETMASK, &set, NULL);
- while (running)
- {
- if (sigwaitinfo(&set, &info) == SIGCHLD)
- {
- enumerator = dumm->create_guest_enumerator(dumm);
- while (enumerator->enumerate(enumerator, &guest))
- {
- if (guest->get_pid(guest) == info.si_pid)
- {
- running--;
- guest->sigchild(guest);
- break;
- }
- }
- enumerator->destroy(enumerator);
- }
- }
- }
- dumm->destroy(dumm);
-
- library_deinit();
- return 0;
-}