diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2008-10-29 20:30:44 +0000 |
commit | 74f0bbfc53cb5fa519e4e27ece53735ab51b397c (patch) | |
tree | 0dbab9c835be15577ff05b474b6361bb326d66ce /src/dumm/guest.h | |
parent | 5c1fa2516bda1ccf8eb00178c0beb196c2020a94 (diff) | |
download | vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.tar.gz vyos-strongswan-74f0bbfc53cb5fa519e4e27ece53735ab51b397c.zip |
- New upstream release.
Diffstat (limited to 'src/dumm/guest.h')
-rw-r--r-- | src/dumm/guest.h | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/dumm/guest.h b/src/dumm/guest.h index 79a47fa62..0e48b1d06 100644 --- a/src/dumm/guest.h +++ b/src/dumm/guest.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2008 Tobias Brunner * Copyright (C) 2007 Martin Willi * Hochschule fuer Technik Rapperswil * @@ -19,11 +20,11 @@ #include <library.h> #include <utils/enumerator.h> -#include "iface.h" - typedef enum guest_state_t guest_state_t; typedef struct guest_t guest_t; +#include "iface.h" + /** * @brief State of a guest (started, stopped, ...) */ @@ -107,9 +108,8 @@ struct guest_t { * @brief Kill the guest. * * @param idle idle function to call while waiting to termination - * @return TRUE if guest was running and killed */ - bool (*stop) (guest_t *this, idle_function_t idle); + void (*stop) (guest_t *this, idle_function_t idle); /** * @brief Create a new interface in the current scenario. @@ -140,7 +140,35 @@ struct guest_t { * @return FALSE if failed */ bool (*load_template)(guest_t *this, char *parent); - + + /** + * Execute a command in the guest. + * + * @param cb callback to call for each read block + * @param data data to pass to callback + * @param cmd command to execute + * @param ... printf style argument list for cmd + * @return return value + */ + int (*exec)(guest_t *this, void(*cb)(void*,char*,size_t), void *data, + char *cmd, ...); + + /** + * Execute a command in the guest and return the output by lines or as combined + * string. + * + * @note This function does not work with binary output (i.e. containing 0 bytes). + * + * @param cb callback to call for each line or for the complete output + * @param lines TRUE if the callback should be called for each line (instead of for the combined output) + * @param data data to pass to callback + * @param cmd command to execute + * @param ... printf style argument list for cmd + * @return return value + */ + int (*exec_str)(guest_t *this, void(*cb)(void*,char*), bool lines, + void *data, char *cmd, ...); + /** * @brief Called whenever a SIGCHILD for the guests PID is received. */ @@ -159,10 +187,11 @@ struct guest_t { * @param name name of the guest to create * @param kernel kernel this guest uses * @param master read-only master filesystem for guest + * @param args additional args to pass to kernel * @param mem amount of memory to give the guest */ guest_t *guest_create(char *parent, char *name, char *kernel, - char *master, int mem); + char *master, char *args); /** * @brief Load a guest created with guest_create(). |