diff options
Diffstat (limited to 'src/dumm')
-rw-r--r-- | src/dumm/Makefile.am | 17 | ||||
-rw-r--r-- | src/dumm/Makefile.in | 69 | ||||
-rw-r--r-- | src/dumm/bridge.h | 14 | ||||
-rw-r--r-- | src/dumm/cowfs.c | 344 | ||||
-rw-r--r-- | src/dumm/cowfs.h | 8 | ||||
-rw-r--r-- | src/dumm/dumm.c | 83 | ||||
-rw-r--r-- | src/dumm/dumm.h | 27 | ||||
-rw-r--r-- | src/dumm/ext/dumm.c | 124 | ||||
-rw-r--r-- | src/dumm/ext/extconf.rb | 21 | ||||
-rw-r--r-- | src/dumm/ext/extconf.rb.in | 19 | ||||
-rw-r--r-- | src/dumm/ext/lib/dumm.rb | 45 | ||||
-rw-r--r-- | src/dumm/ext/lib/dumm/guest.rb | 26 | ||||
-rw-r--r-- | src/dumm/guest.c | 9 | ||||
-rw-r--r-- | src/dumm/guest.h | 30 | ||||
-rw-r--r-- | src/dumm/iface.h | 16 | ||||
-rw-r--r-- | src/dumm/mconsole.c | 7 | ||||
-rw-r--r-- | src/dumm/mconsole.h | 10 |
17 files changed, 535 insertions, 334 deletions
diff --git a/src/dumm/Makefile.am b/src/dumm/Makefile.am index 029290fb6..b7fb3f7c8 100644 --- a/src/dumm/Makefile.am +++ b/src/dumm/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = ext/dumm.c ext/extconf.rb ext/README \ +EXTRA_DIST = ext/dumm.c ext/README \ ext/lib/dumm.rb ext/lib/dumm/guest.rb lib_LTLIBRARIES = libdumm.la @@ -15,5 +15,18 @@ dumm_LDADD = libdumm.la ${gtk_LIBS} irdumm_LDADD = libdumm.la -lruby1.8 INCLUDES = -I$(top_srcdir)/src/libstrongswan ${gtk_CFLAGS} \ - -I/usr/lib/ruby/1.8/i486-linux/ + ${RUBYINCLUDE} AM_CFLAGS = -D_FILE_OFFSET_BITS=64 + +all-local: ext + +clean-local: + (test -f ext/Makefile && cd ext && $(MAKE) clean && rm Makefile || true) + +install-data-local: + (test -f ext/Makefile && cd ext && $(MAKE) install) + +ext: libdumm.la + (cd ext && $(RUBY) extconf.rb && $(MAKE)) + +.PHONY: ext diff --git a/src/dumm/Makefile.in b/src/dumm/Makefile.in index 6cf2a88af..fdbf41f47 100644 --- a/src/dumm/Makefile.in +++ b/src/dumm/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -97,6 +97,7 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLLIB = @DLLIB@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -119,6 +120,9 @@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -130,6 +134,7 @@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ @@ -143,6 +148,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ RANLIB = @RANLIB@ +RUBY = @RUBY@ +RUBYINCLUDE = @RUBYINCLUDE@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -203,6 +210,7 @@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ plugindir = @plugindir@ +pluto_plugins = @pluto_plugins@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ @@ -214,11 +222,12 @@ srcdir = @srcdir@ strongswan_conf = @strongswan_conf@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ xml_CFLAGS = @xml_CFLAGS@ xml_LIBS = @xml_LIBS@ -EXTRA_DIST = ext/dumm.c ext/extconf.rb ext/README \ +EXTRA_DIST = ext/dumm.c ext/README \ ext/lib/dumm.rb ext/lib/dumm/guest.rb lib_LTLIBRARIES = libdumm.la @@ -233,7 +242,7 @@ libdumm_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la \ dumm_LDADD = libdumm.la ${gtk_LIBS} irdumm_LDADD = libdumm.la -lruby1.8 INCLUDES = -I$(top_srcdir)/src/libstrongswan ${gtk_CFLAGS} \ - -I/usr/lib/ruby/1.8/i486-linux/ + ${RUBYINCLUDE} AM_CFLAGS = -D_FILE_OFFSET_BITS=64 all: all-am @@ -244,8 +253,8 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -380,7 +389,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -450,7 +459,7 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) all-local installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(ipsecdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ @@ -482,7 +491,7 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-generic clean-ipsecPROGRAMS clean-libLTLIBRARIES \ - clean-libtool mostlyclean-am + clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -500,7 +509,7 @@ info: info-am info-am: -install-data-am: install-ipsecPROGRAMS +install-data-am: install-data-local install-ipsecPROGRAMS install-dvi: install-dvi-am @@ -540,21 +549,35 @@ uninstall-am: uninstall-ipsecPROGRAMS uninstall-libLTLIBRARIES .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-ipsecPROGRAMS clean-libLTLIBRARIES clean-libtool ctags \ - distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-ipsecPROGRAMS install-libLTLIBRARIES \ - install-man install-pdf install-pdf-am install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-ipsecPROGRAMS uninstall-libLTLIBRARIES +.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ + clean-generic clean-ipsecPROGRAMS clean-libLTLIBRARIES \ + clean-libtool clean-local ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-data-local install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-ipsecPROGRAMS install-libLTLIBRARIES install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-ipsecPROGRAMS uninstall-libLTLIBRARIES + + +all-local: ext + +clean-local: + (test -f ext/Makefile && cd ext && $(MAKE) clean && rm Makefile || true) + +install-data-local: + (test -f ext/Makefile && cd ext && $(MAKE) install) + +ext: libdumm.la + (cd ext && $(RUBY) extconf.rb && $(MAKE)) +.PHONY: ext # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/dumm/bridge.h b/src/dumm/bridge.h index 79a0a3a72..37b22a03e 100644 --- a/src/dumm/bridge.h +++ b/src/dumm/bridge.h @@ -24,19 +24,19 @@ typedef struct bridge_t bridge_t; #include "iface.h" /** - * @brief Interface in a guest, connected to a tap device on the host. + * Interface in a guest, connected to a tap device on the host. */ struct bridge_t { /** - * @brief Get the name of the bridge. + * Get the name of the bridge. * * @return name of the bridge */ char* (*get_name)(bridge_t *this); /** - * @brief Add an interface to a bridge. + * Add an interface to a bridge. * * @param iface interface to add * @return TRUE if interface added @@ -44,7 +44,7 @@ struct bridge_t { bool (*connect_iface)(bridge_t *this, iface_t *iface); /** - * @brief Remove an interface from a bridge. + * Remove an interface from a bridge. * * @param iface interface to remove * @return TRUE if interface removed @@ -52,20 +52,20 @@ struct bridge_t { bool (*disconnect_iface)(bridge_t *this, iface_t *iface); /** - * @brief Create an enumerator over all interfaces. + * Create an enumerator over all interfaces. * * @return enumerator over iface_t's */ enumerator_t* (*create_iface_enumerator)(bridge_t *this); /** - * @brief Destroy a bridge + * Destroy a bridge */ void (*destroy) (bridge_t *this); }; /** - * @brief Create a new bridge. + * Create a new bridge. * * @param name name of the bridge to create * @return bridge, NULL if failed diff --git a/src/dumm/cowfs.c b/src/dumm/cowfs.c index 88041811e..69f008976 100644 --- a/src/dumm/cowfs.c +++ b/src/dumm/cowfs.c @@ -96,7 +96,7 @@ static void rel(const char **path) static int get_rd(const char *path) { private_cowfs_t *this = get_this(); - + if (this->over_fd > 0 && faccessat(this->over_fd, path, F_OK, 0) == 0) { return this->over_fd; @@ -223,7 +223,7 @@ static int copy(const char *path) static int cowfs_getattr(const char *path, struct stat *stbuf) { rel(&path); - + if (fstatat(get_rd(path), path, stbuf, AT_SYMLINK_NOFOLLOW) < 0) { return -errno; @@ -242,7 +242,7 @@ static int cowfs_access(const char *path, int mask) { return -errno; } - return 0; + return 0; } /** @@ -251,16 +251,16 @@ static int cowfs_access(const char *path, int mask) static int cowfs_readlink(const char *path, char *buf, size_t size) { int res; - + rel(&path); res = readlinkat(get_rd(path), path, buf, size - 1); - if (res < 0) - { - return -errno; + if (res < 0) + { + return -errno; } - buf[res] = '\0'; - return 0; + buf[res] = '\0'; + return 0; } /** @@ -329,7 +329,7 @@ static int cowfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, { st.st_ino = ent->d_ino; st.st_mode = ent->d_type << 12; - filler(buf, ent->d_name, &st, 0); + filler(buf, ent->d_name, &st, 0); } } closedir(d1); @@ -343,7 +343,7 @@ static int cowfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, { st.st_ino = ent->d_ino; st.st_mode = ent->d_type << 12; - filler(buf, ent->d_name, &st, 0); + filler(buf, ent->d_name, &st, 0); } } closedir(d2); @@ -355,11 +355,11 @@ static int cowfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, { st.st_ino = ent->d_ino; st.st_mode = ent->d_type << 12; - filler(buf, ent->d_name, &st, 0); + filler(buf, ent->d_name, &st, 0); } closedir(d3); } - return 0; + return 0; } /** @@ -369,13 +369,13 @@ static int cowfs_mknod(const char *path, mode_t mode, dev_t rdev) { int fd; rel(&path); - + fd = get_wr(path); if (!clone_path(get_rd(path), fd, path)) { return -errno; } - + if (mknodat(fd, path, mode, rdev) < 0) { return -errno; @@ -390,7 +390,7 @@ static int cowfs_mkdir(const char *path, mode_t mode) { int fd; rel(&path); - + fd = get_wr(path); if (!clone_path(get_rd(path), fd, path)) { @@ -415,7 +415,7 @@ static int cowfs_unlink(const char *path) { return -errno; } - return 0; + return 0; } /** @@ -430,7 +430,7 @@ static int cowfs_rmdir(const char *path) { return -errno; } - return 0; + return 0; } /** @@ -440,10 +440,10 @@ static int cowfs_symlink(const char *from, const char *to) { int fd; const char *fromrel = from; - + rel(&to); rel(&fromrel); - + fd = get_wr(to); if (!clone_path(get_rd(fromrel), fd, fromrel)) { @@ -462,24 +462,18 @@ static int cowfs_symlink(const char *from, const char *to) static int cowfs_rename(const char *from, const char *to) { int fd; - private_cowfs_t *this = get_this(); - + rel(&from); rel(&to); - - fd = get_rd(from); - if (fd == this->master_fd) + + fd = copy(from); + if (fd < 0) { - fd = copy(from); - if (fd < 0) - { - return -errno; - } + return -errno; } - if (renameat(fd, from, get_wr(to), to) < 0) { - return -errno; + return -errno; } return 0; } @@ -490,7 +484,7 @@ static int cowfs_rename(const char *from, const char *to) static int cowfs_link(const char *from, const char *to) { int rd, wr; - + rel(&from); rel(&to); @@ -502,12 +496,12 @@ static int cowfs_link(const char *from, const char *to) DBG1("cloning path '%s' failed", to); return -errno; } - if (linkat(rd, from, wr, to, 0) < 0) - { + if (linkat(rd, from, wr, to, 0) < 0) + { DBG1("linking '%s' to '%s' failed", from, to); - return -errno; + return -errno; } - return 0; + return 0; } /** @@ -517,25 +511,21 @@ static int cowfs_chmod(const char *path, mode_t mode) { int fd; struct stat st; - private_cowfs_t *this = get_this(); rel(&path); fd = get_rd(path); - if (fd == this->master_fd) + if (fstatat(fd, path, &st, 0) < 0) { - if (fstatat(fd, path, &st, 0) < 0) - { - return -errno; - } - if (st.st_mode == mode) - { - return 0; - } - fd = copy(path); - if (fd < 0) - { - return -errno; - } + return -errno; + } + if (st.st_mode == mode) + { + return 0; + } + fd = copy(path); + if (fd < 0) + { + return -errno; } if (fchmodat(fd, path, mode, 0) < 0) { @@ -551,25 +541,21 @@ static int cowfs_chown(const char *path, uid_t uid, gid_t gid) { int fd; struct stat st; - private_cowfs_t *this = get_this(); rel(&path); fd = get_rd(path); - if (fd == this->master_fd) + if (fstatat(fd, path, &st, 0) < 0) { - if (fstatat(fd, path, &st, 0) < 0) - { - return -errno; - } - if (st.st_uid == uid && st.st_gid == gid) - { - return 0; - } - fd = copy(path); - if (fd < 0) - { - return -errno; - } + return -errno; + } + if (st.st_uid == uid && st.st_gid == gid) + { + return 0; + } + fd = copy(path); + if (fd < 0) + { + return -errno; } if (fchownat(fd, path, uid, gid, AT_SYMLINK_NOFOLLOW) < 0) { @@ -586,25 +572,20 @@ static int cowfs_truncate(const char *path, off_t size) int fd; struct stat st; - private_cowfs_t *this = get_this(); - rel(&path); fd = get_rd(path); - if (fd == this->master_fd) + if (fstatat(fd, path, &st, 0) < 0) { - if (fstatat(fd, path, &st, 0) < 0) - { - return -errno; - } - if (st.st_size == size) - { - return 0; - } - fd = copy(path); - if (fd < 0) - { - return -errno; - } + return -errno; + } + if (st.st_size == size) + { + return 0; + } + fd = copy(path); + if (fd < 0) + { + return -errno; } fd = openat(fd, path, O_WRONLY); if (fd < 0) @@ -627,24 +608,19 @@ static int cowfs_utimens(const char *path, const struct timespec ts[2]) { struct timeval tv[2]; int fd; - private_cowfs_t *this = get_this(); - + rel(&path); - fd = get_rd(path); - if (fd == this->master_fd) + fd = copy(path); + if (fd < 0) { - fd = copy(path); - if (fd < 0) - { - return -errno; - } + return -errno; } - + tv[0].tv_sec = ts[0].tv_sec; tv[0].tv_usec = ts[0].tv_nsec / 1000; tv[1].tv_sec = ts[1].tv_sec; tv[1].tv_usec = ts[1].tv_nsec / 1000; - + if (futimesat(fd, path, tv) < 0) { return -errno; @@ -658,10 +634,10 @@ static int cowfs_utimens(const char *path, const struct timespec ts[2]) static int cowfs_open(const char *path, struct fuse_file_info *fi) { int fd; - + rel(&path); fd = get_rd(path); - + fd = openat(fd, path, fi->flags); if (fd < 0) { @@ -678,11 +654,11 @@ static int cowfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int file, fd, res; - + rel(&path); - + fd = get_rd(path); - + file = openat(fd, path, O_RDONLY); if (file < 0) { @@ -704,20 +680,14 @@ static int cowfs_read(const char *path, char *buf, size_t size, off_t offset, static int cowfs_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { - private_cowfs_t *this = get_this(); int file, fd, res; - + rel(&path); - - fd = get_wr(path); - if (fd == this->master_fd || - (this->over_fd > 0 && fd == this->host_fd)) + + fd = copy(path); + if (fd < 0) { - fd = copy(path); - if (fd < 0) - { - return -errno; - } + return -errno; } file = openat(fd, path, O_WRONLY); if (file < 0) @@ -738,21 +708,15 @@ static int cowfs_write(const char *path, const char *buf, size_t size, */ static int cowfs_statfs(const char *path, struct statvfs *stbuf) { - private_cowfs_t *this = get_this(); int fd; - fd = this->host_fd; - if (this->over_fd > 0) - { - fd = this->over_fd; - } - + fd = get_rd(path); if (fstatvfs(fd, stbuf) < 0) { return -errno; } - return 0; + return 0; } /** @@ -771,26 +735,26 @@ static void *cowfs_init(struct fuse_conn_info *conn) * FUSE method vectors */ static struct fuse_operations cowfs_operations = { - .getattr = cowfs_getattr, - .access = cowfs_access, - .readlink = cowfs_readlink, - .readdir = cowfs_readdir, - .mknod = cowfs_mknod, - .mkdir = cowfs_mkdir, - .symlink = cowfs_symlink, - .unlink = cowfs_unlink, - .rmdir = cowfs_rmdir, - .rename = cowfs_rename, - .link = cowfs_link, - .chmod = cowfs_chmod, - .chown = cowfs_chown, - .truncate = cowfs_truncate, - .utimens = cowfs_utimens, - .open = cowfs_open, - .read = cowfs_read, - .write = cowfs_write, - .statfs = cowfs_statfs, - .init = cowfs_init, + .getattr = cowfs_getattr, + .access = cowfs_access, + .readlink = cowfs_readlink, + .readdir = cowfs_readdir, + .mknod = cowfs_mknod, + .mkdir = cowfs_mkdir, + .symlink = cowfs_symlink, + .unlink = cowfs_unlink, + .rmdir = cowfs_rmdir, + .rename = cowfs_rename, + .link = cowfs_link, + .chmod = cowfs_chmod, + .chown = cowfs_chown, + .truncate = cowfs_truncate, + .utimens = cowfs_utimens, + .open = cowfs_open, + .read = cowfs_read, + .write = cowfs_write, + .statfs = cowfs_statfs, + .init = cowfs_init, }; /** @@ -854,63 +818,63 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) this->public.set_overlay = (bool(*)(cowfs_t*, char *path))set_overlay; this->public.destroy = (void(*)(cowfs_t*))destroy; - this->master_fd = open(master, O_RDONLY | O_DIRECTORY); - if (this->master_fd < 0) - { - DBG1("failed to open master filesystem '%s'", master); - free(this); - return NULL; - } - this->host_fd = open(host, O_RDONLY | O_DIRECTORY); + this->master_fd = open(master, O_RDONLY | O_DIRECTORY); + if (this->master_fd < 0) + { + DBG1("failed to open master filesystem '%s'", master); + free(this); + return NULL; + } + this->host_fd = open(host, O_RDONLY | O_DIRECTORY); if (this->host_fd < 0) - { - DBG1("failed to open host filesystem '%s'", host); - close(this->master_fd); - free(this); - return NULL; - } + { + DBG1("failed to open host filesystem '%s'", host); + close(this->master_fd); + free(this); + return NULL; + } this->over_fd = -1; - this->chan = fuse_mount(mount, &args); - if (this->chan == NULL) - { - DBG1("mounting cowfs FUSE on '%s' failed", mount); - close(this->master_fd); - close(this->host_fd); - free(this); - return NULL; - } - - this->fuse = fuse_new(this->chan, &args, &cowfs_operations, - sizeof(cowfs_operations), this); - if (this->fuse == NULL) - { - DBG1("creating cowfs FUSE handle failed"); - close(this->master_fd); - close(this->host_fd); - fuse_unmount(mount, this->chan); - free(this); - return NULL; - } - - this->mount = strdup(mount); - this->master = strdup(master); - this->host = strdup(host); - this->over = NULL; + this->chan = fuse_mount(mount, &args); + if (this->chan == NULL) + { + DBG1("mounting cowfs FUSE on '%s' failed", mount); + close(this->master_fd); + close(this->host_fd); + free(this); + return NULL; + } + + this->fuse = fuse_new(this->chan, &args, &cowfs_operations, + sizeof(cowfs_operations), this); + if (this->fuse == NULL) + { + DBG1("creating cowfs FUSE handle failed"); + close(this->master_fd); + close(this->host_fd); + fuse_unmount(mount, this->chan); + free(this); + return NULL; + } + + this->mount = strdup(mount); + this->master = strdup(master); + this->host = strdup(host); + this->over = NULL; if (pthread_create(&this->thread, NULL, (void*)fuse_loop, this->fuse) != 0) { - DBG1("creating thread to handle FUSE failed"); - fuse_unmount(mount, this->chan); - free(this->mount); - free(this->master); - free(this->host); - close(this->master_fd); - close(this->host_fd); - free(this); - return NULL; - } - - return &this->public; + DBG1("creating thread to handle FUSE failed"); + fuse_unmount(mount, this->chan); + free(this->mount); + free(this->master); + free(this->host); + close(this->master_fd); + close(this->host_fd); + free(this); + return NULL; + } + + return &this->public; } diff --git a/src/dumm/cowfs.h b/src/dumm/cowfs.h index 419197dd6..bb589f158 100644 --- a/src/dumm/cowfs.h +++ b/src/dumm/cowfs.h @@ -21,13 +21,13 @@ typedef struct cowfs_t cowfs_t; /** - * @brief cowfs - Copy on write FUSE filesystem. + * cowfs - Copy on write FUSE filesystem. * */ struct cowfs_t { /** - * @brief Set an additional copy on write overlay. + * Set an additional copy on write overlay. * * @param path path of the overlay * @return FALSE if failed @@ -35,13 +35,13 @@ struct cowfs_t { bool (*set_overlay)(cowfs_t *this, char *path); /** - * @brief Stop, umount and destroy a cowfs FUSE filesystem. + * Stop, umount and destroy a cowfs FUSE filesystem. */ void (*destroy) (cowfs_t *this); }; /** - * @brief Mount a cowfs FUSE filesystem. + * Mount a cowfs FUSE filesystem. * * @param master read only master file system directory * @param host copy on write host directory diff --git a/src/dumm/dumm.c b/src/dumm/dumm.c index cf8d9719c..2cb1235e1 100644 --- a/src/dumm/dumm.c +++ b/src/dumm/dumm.c @@ -28,8 +28,9 @@ #include "dumm.h" -#define PERME (S_IRWXU | S_IRWXG) +#define PERME (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) #define GUEST_DIR "guests" +#define TEMPLATE_DIR "templates" typedef struct private_dumm_t private_dumm_t; @@ -133,10 +134,10 @@ static void clear_template(private_dumm_t *this) { enumerator_t *enumerator; guest_t *guest; - + free(this->template); this->template = NULL; - + enumerator = this->guests->create_enumerator(this->guests); while (enumerator->enumerate(enumerator, (void**)&guest)) { @@ -165,7 +166,11 @@ static bool load_template(private_dumm_t *this, char *dir) return FALSE; } - this->template = strdup(dir); + if (asprintf(&this->template, "%s/%s", TEMPLATE_DIR, dir) < 0) + { + this->template = NULL; + return FALSE; + } if (access(this->template, F_OK) != 0) { /* does not exist, create template */ if (!mkdir_p(this->template, PERME)) @@ -189,13 +194,66 @@ static bool load_template(private_dumm_t *this, char *dir) } /** + * Template directory enumerator + */ +typedef struct { + /** implements enumerator_t */ + enumerator_t public; + /** directory enumerator */ + enumerator_t *inner; +} template_enumerator_t; + +/** + * Implementation of template_enumerator_t.enumerate + */ +static bool template_enumerate(template_enumerator_t *this, char **template) +{ + struct stat st; + char *rel; + + while (this->inner->enumerate(this->inner, &rel, NULL, &st)) + { + if (S_ISDIR(st.st_mode) && *rel != '.') + { + *template = rel; + return TRUE; + } + } + return FALSE; +} + +/** + * Implementation of template_enumerator_t.destroy + */ +static void template_enumerator_destroy(template_enumerator_t *this) +{ + this->inner->destroy(this->inner); + free(this); +} + +/** + * Implementation of dumm_t.create_template_enumerator + */ +static enumerator_t* create_template_enumerator(private_dumm_t *this) +{ + template_enumerator_t *enumerator; + + enumerator = malloc_thing(template_enumerator_t); + enumerator->public.enumerate = (void*)template_enumerate; + enumerator->public.destroy = (void*)template_enumerator_destroy; + enumerator->inner = enumerator_create_directory(TEMPLATE_DIR); + + return &enumerator->public; +} + +/** * Implementation of dumm_t.destroy */ static void destroy(private_dumm_t *this) { enumerator_t *enumerator; guest_t *guest; - + this->bridges->destroy_offset(this->bridges, offsetof(bridge_t, destroy)); enumerator = this->guests->create_enumerator(this->guests); @@ -233,8 +291,8 @@ static void load_guests(private_dumm_t *this) while ((ent = readdir(dir))) { - if (streq(ent->d_name, ".") || streq(ent->d_name, "..")) - { + if (*ent->d_name == '.') + { /* skip ".", ".." and hidden files (such as ".svn") */ continue; } guest = guest_load(this->guest_dir, ent->d_name); @@ -265,6 +323,7 @@ dumm_t *dumm_create(char *dir) this->public.create_bridge_enumerator = (enumerator_t*(*)(dumm_t*))create_bridge_enumerator; this->public.delete_bridge = (void(*)(dumm_t*,bridge_t*))delete_bridge; this->public.load_template = (bool(*)(dumm_t*, char *name))load_template; + this->public.create_template_enumerator = (enumerator_t*(*)(dumm_t*))create_template_enumerator; this->public.destroy = (void(*)(dumm_t*))destroy; if (dir && *dir == '/') @@ -273,11 +332,11 @@ dumm_t *dumm_create(char *dir) } else { - if (getcwd(cwd, sizeof(cwd)) == NULL) - { - free(this); - return NULL; - } + if (getcwd(cwd, sizeof(cwd)) == NULL) + { + free(this); + return NULL; + } if (dir) { if (asprintf(&this->dir, "%s/%s", cwd, dir) < 0) diff --git a/src/dumm/dumm.h b/src/dumm/dumm.h index f5db0e45b..5f2e0542a 100644 --- a/src/dumm/dumm.h +++ b/src/dumm/dumm.h @@ -28,14 +28,14 @@ typedef struct dumm_t dumm_t; /** - * @brief dumm - Dynamic Uml Mesh Modeler + * dumm - Dynamic Uml Mesh Modeler * * Controls a group of UML guests and their networks. */ struct dumm_t { /** - * @brief Starts a new UML guest + * Starts a new UML guest * * @param name name of the guest * @param kernel UML kernel to use for guest @@ -47,21 +47,21 @@ struct dumm_t { char *master, char *args); /** - * @brief Create an enumerator over all guests. + * Create an enumerator over all guests. * * @return enumerator over guest_t's */ enumerator_t* (*create_guest_enumerator) (dumm_t *this); /** - * @brief Delete a guest from disk. + * Delete a guest from disk. * * @param guest guest to destroy */ void (*delete_guest) (dumm_t *this, guest_t *guest); /** - * @brief Create a new bridge. + * Create a new bridge. * * @param name name of the bridge to create * @return created bridge @@ -69,21 +69,21 @@ struct dumm_t { bridge_t* (*create_bridge)(dumm_t *this, char *name); /** - * @brief Create an enumerator over all bridges. + * Create an enumerator over all bridges. * * @return enumerator over bridge_t's */ enumerator_t* (*create_bridge_enumerator)(dumm_t *this); /** - * @brief Delete a bridge. + * Delete a bridge. * * @param bridge bridge to destroy */ void (*delete_bridge) (dumm_t *this, bridge_t *bridge); /** - * @brief Loads a template, create a new one if it does not exist. + * Loads a template, create a new one if it does not exist. * * @param name dir to the template, NULL to close * @return FALSE if load/create failed @@ -91,13 +91,20 @@ struct dumm_t { bool (*load_template)(dumm_t *this, char *dir); /** - * @brief stop all guests and destroy the modeler + * Create an enumerator over all available templates. + * + * @return enumerator over char* + */ + enumerator_t* (*create_template_enumerator)(dumm_t *this); + + /** + * stop all guests and destroy the modeler */ void (*destroy) (dumm_t *this); }; /** - * @brief Create a group of UML hosts and networks. + * Create a group of UML hosts and networks. * * @param dir directory to create guests/load from, NULL for cwd * @return created UML group, or NULL if failed. diff --git a/src/dumm/ext/dumm.c b/src/dumm/ext/dumm.c index 2610affc3..f7caf252d 100644 --- a/src/dumm/ext/dumm.c +++ b/src/dumm/ext/dumm.c @@ -12,8 +12,6 @@ * 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. - * - * $Id: dumm.c 4447 2008-10-15 14:47:52Z martin $ */ #include <stdio.h> @@ -24,11 +22,13 @@ #include <library.h> #include <dumm.h> #include <debug.h> +#include <utils/linked_list.h> #undef PACKAGE_NAME #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #undef PACKAGE_STRING +#undef PACKAGE_BUGREPORT #include <ruby.h> static dumm_t *dumm; @@ -84,8 +84,6 @@ static void sigchld_handler(int signal, siginfo_t *info, void* ptr) enumerator->destroy(enumerator); } - - /** * Guest bindings */ @@ -93,7 +91,9 @@ static VALUE guest_find(VALUE class, VALUE key) { enumerator_t *enumerator; guest_t *guest, *found = NULL; - if (TYPE(key) == T_SYMBOL) { + + if (TYPE(key) == T_SYMBOL) + { key = rb_convert_type(key, T_STRING, "String", "to_s"); } enumerator = dumm->create_guest_enumerator(dumm); @@ -125,19 +125,26 @@ static VALUE guest_get(VALUE class, VALUE key) static VALUE guest_each(int argc, VALUE *argv, VALUE class) { + linked_list_t *list; enumerator_t *enumerator; guest_t *guest; - + if (!rb_block_given_p()) - { + { rb_raise(rb_eArgError, "must be called with a block"); } + list = linked_list_create(); enumerator = dumm->create_guest_enumerator(dumm); while (enumerator->enumerate(enumerator, &guest)) { - rb_yield(Data_Wrap_Struct(class, NULL, NULL, guest)); + list->insert_last(list, guest); } enumerator->destroy(enumerator); + while (list->remove_first(list, (void**)&guest) == SUCCESS) + { + rb_yield(Data_Wrap_Struct(class, NULL, NULL, guest)); + } + list->destroy(list); return class; } @@ -249,7 +256,9 @@ static VALUE guest_find_iface(VALUE self, VALUE key) enumerator_t *enumerator; iface_t *iface, *found = NULL; guest_t *guest; - if (TYPE(key) == T_SYMBOL) { + + if (TYPE(key) == T_SYMBOL) + { key = rb_convert_type(key, T_STRING, "String", "to_s"); } Data_Get_Struct(self, guest_t, guest); @@ -283,20 +292,27 @@ static VALUE guest_get_iface(VALUE self, VALUE key) static VALUE guest_each_iface(int argc, VALUE *argv, VALUE self) { enumerator_t *enumerator; + linked_list_t *list; guest_t *guest; iface_t *iface; - + if (!rb_block_given_p()) - { + { rb_raise(rb_eArgError, "must be called with a block"); } Data_Get_Struct(self, guest_t, guest); + list = linked_list_create(); enumerator = guest->create_iface_enumerator(guest); while (enumerator->enumerate(enumerator, &iface)) { - rb_yield(Data_Wrap_Struct(rbc_iface, NULL, NULL, iface)); + list->insert_last(list, iface); } enumerator->destroy(enumerator); + while (list->remove_first(list, (void**)&iface) == SUCCESS) + { + rb_yield(Data_Wrap_Struct(rbc_iface, NULL, NULL, iface)); + } + list->destroy(list); return self; } @@ -305,6 +321,10 @@ static VALUE guest_delete(VALUE self) guest_t *guest; Data_Get_Struct(self, guest_t, guest); + if (guest->get_pid(guest)) + { + rb_raise(rb_eRuntimeError, "guest is running"); + } dumm->delete_guest(dumm, guest); return Qnil; } @@ -338,11 +358,15 @@ static void guest_init() /** * Bridge binding */ -static VALUE bridge_get(VALUE class, VALUE key) +static VALUE bridge_find(VALUE class, VALUE key) { enumerator_t *enumerator; bridge_t *bridge, *found = NULL; + if (TYPE(key) == T_SYMBOL) + { + key = rb_convert_type(key, T_STRING, "String", "to_s"); + } enumerator = dumm->create_bridge_enumerator(dumm); while (enumerator->enumerate(enumerator, &bridge)) { @@ -355,26 +379,43 @@ static VALUE bridge_get(VALUE class, VALUE key) enumerator->destroy(enumerator); if (!found) { - rb_raise(rb_eRuntimeError, "bridge not found"); + return Qnil; } return Data_Wrap_Struct(class, NULL, NULL, found); } +static VALUE bridge_get(VALUE class, VALUE key) +{ + VALUE bridge = bridge_find(class, key); + if (NIL_P(bridge)) + { + rb_raise(rb_eRuntimeError, "bridge not found"); + } + return bridge; +} + static VALUE bridge_each(int argc, VALUE *argv, VALUE class) { enumerator_t *enumerator; + linked_list_t *list; bridge_t *bridge; - + if (!rb_block_given_p()) - { + { rb_raise(rb_eArgError, "must be called with a block"); } + list = linked_list_create(); enumerator = dumm->create_bridge_enumerator(dumm); while (enumerator->enumerate(enumerator, &bridge)) { - rb_yield(Data_Wrap_Struct(class, NULL, NULL, bridge)); + list->insert_last(list, bridge); } enumerator->destroy(enumerator); + while (list->remove_first(list, (void**)&bridge) == SUCCESS) + { + rb_yield(Data_Wrap_Struct(class, NULL, NULL, bridge)); + } + list->destroy(list); return class; } @@ -402,20 +443,27 @@ static VALUE bridge_to_s(VALUE self) static VALUE bridge_each_iface(int argc, VALUE *argv, VALUE self) { enumerator_t *enumerator; + linked_list_t *list; bridge_t *bridge; iface_t *iface; - + if (!rb_block_given_p()) - { + { rb_raise(rb_eArgError, "must be called with a block"); } Data_Get_Struct(self, bridge_t, bridge); + list = linked_list_create(); enumerator = bridge->create_iface_enumerator(bridge); while (enumerator->enumerate(enumerator, &iface)) { - rb_yield(Data_Wrap_Struct(rbc_iface, NULL, NULL, iface)); + list->insert_last(list, iface); } enumerator->destroy(enumerator); + while (list->remove_first(list, (void**)&iface) == SUCCESS) + { + rb_yield(Data_Wrap_Struct(rbc_iface, NULL, NULL, iface)); + } + list->destroy(list); return self; } @@ -437,6 +485,8 @@ static void bridge_init() rb_define_singleton_method(rbc_bridge, "[]", bridge_get, 1); rb_define_singleton_method(rbc_bridge, "each", bridge_each, -1); rb_define_singleton_method(rbc_bridge, "new", bridge_new, 1); + rb_define_singleton_method(rbc_bridge, "include?", bridge_find, 1); + rb_define_singleton_method(rbc_bridge, "bridge?", bridge_find, 1); rb_define_method(rbc_bridge, "to_s", bridge_to_s, 0); rb_define_method(rbc_bridge, "each", bridge_each_iface, -1); @@ -509,22 +559,29 @@ static VALUE iface_add_addr(VALUE self, VALUE name) static VALUE iface_each_addr(int argc, VALUE *argv, VALUE self) { enumerator_t *enumerator; + linked_list_t *list; iface_t *iface; host_t *addr; char buf[64]; - + if (!rb_block_given_p()) - { + { rb_raise(rb_eArgError, "must be called with a block"); } Data_Get_Struct(self, iface_t, iface); enumerator = iface->create_address_enumerator(iface); while (enumerator->enumerate(enumerator, &addr)) { - snprintf(buf, sizeof(buf), "%H", addr); - rb_yield(rb_str_new2(buf)); + list->insert_last(list, addr->clone(addr)); } enumerator->destroy(enumerator); + while (list->remove_first(list, (void**)&addr) == SUCCESS) + { + snprintf(buf, sizeof(buf), "%H", addr); + addr->destroy(addr); + rb_yield(rb_str_new2(buf)); + } + list->destroy(list); return self; } @@ -595,12 +652,31 @@ static VALUE template_unload(VALUE class) return class; } +static VALUE template_each(int argc, VALUE *argv, VALUE class) +{ + enumerator_t *enumerator; + char *template; + + if (!rb_block_given_p()) + { + rb_raise(rb_eArgError, "must be called with a block"); + } + enumerator = dumm->create_template_enumerator(dumm); + while (enumerator->enumerate(enumerator, &template)) + { + rb_yield(rb_str_new2(template)); + } + enumerator->destroy(enumerator); + return class; +} + static void template_init() { rbc_template = rb_define_class_under(rbm_dumm , "Template", rb_cObject); rb_define_singleton_method(rbc_template, "load", template_load, 1); rb_define_singleton_method(rbc_template, "unload", template_unload, 0); + rb_define_singleton_method(rbc_template, "each", template_each, -1); } /** diff --git a/src/dumm/ext/extconf.rb b/src/dumm/ext/extconf.rb deleted file mode 100644 index 136be5c2c..000000000 --- a/src/dumm/ext/extconf.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# DUMM for Ruby -# - -require "mkmf" - -dir_config("dumm") - -unless find_header('library.h', '../../libstrongswan') and - find_header('dumm.h', '..') - puts "... failed: one or more header files not found!" - exit -end - -unless find_library('dumm', 'dumm_create') - puts "... failed: 'libdumm' not found!" - exit -end - -create_makefile("dumm") - diff --git a/src/dumm/ext/extconf.rb.in b/src/dumm/ext/extconf.rb.in new file mode 100644 index 000000000..36536ec52 --- /dev/null +++ b/src/dumm/ext/extconf.rb.in @@ -0,0 +1,19 @@ +# +# DUMM for Ruby +# + +require 'mkmf' + +$defs << " @DEFS@" +$CFLAGS << " -Wno-format" + +dir_config('dumm', '@top_srcdir@/src/dumm', '../.libs') +dir_config('strongswan', '@top_srcdir@/src/libstrongswan', '../../libstrongswan/.libs') + +unless find_library('dumm', 'dumm_create') + puts "... failed: 'libdumm' not found!" + exit +end + +create_makefile('dumm', '@top_srcdir@/src/dumm/ext') + diff --git a/src/dumm/ext/lib/dumm.rb b/src/dumm/ext/lib/dumm.rb index 2e860ae9f..25939e9f4 100644 --- a/src/dumm/ext/lib/dumm.rb +++ b/src/dumm/ext/lib/dumm.rb @@ -11,11 +11,52 @@ 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. - - $Id: dumm.rb 4295 2008-08-27 07:35:20Z tobias $ =end require 'dumm.so' require 'dumm/guest' +module Dumm + + # use guest/bridge indentifiers directly + def method_missing(id, *args) + if Guest.guest? id + return Guest[id] + end + if Bridge.bridge? id + return Bridge[id] + end + super(id, *args) + end + + # shortcut for Template loading + def template(name = nil) + if name + Template.load name + else + Template.each {|t| puts t } + end + end + + # unload templates, reset all guests and delete bridges + def reset + Template.unload + Guest.each { |guest| + guest.reset if guest.running? + } + Bridge.each { |bridge| + bridge.delete + } + return Dumm + end + + # wait until all running guests have booted up + def boot + Guest.each {|g| + g.boot if g.running? + } + return Dumm + end +end + # vim:sw=2 ts=2 et diff --git a/src/dumm/ext/lib/dumm/guest.rb b/src/dumm/ext/lib/dumm/guest.rb index bdd0c33d8..936f512dd 100644 --- a/src/dumm/ext/lib/dumm/guest.rb +++ b/src/dumm/ext/lib/dumm/guest.rb @@ -11,8 +11,6 @@ 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. - - $Id: guest.rb 4295 2008-08-27 07:35:20Z tobias $ =end module Dumm @@ -34,6 +32,30 @@ module Dumm end self[id] end + + # delete all interfaces + def reset + each {|i| + i.delete + } + end + + # has the guest booted up? + def booted? + begin + exec("pgrep getty") + rescue + return false + end + return true + end + + # wait until the guest has booted + def boot + while not booted? + sleep(1) + end + end end end diff --git a/src/dumm/guest.c b/src/dumm/guest.c index 014a9113f..969a2a99d 100644 --- a/src/dumm/guest.c +++ b/src/dumm/guest.c @@ -36,8 +36,8 @@ #include "mconsole.h" #include "cowfs.h" -#define PERME (S_IRWXU | S_IRWXG) -#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) +#define PERME (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) +#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define MASTER_DIR "master" #define DIFF_DIR "diff" @@ -300,7 +300,6 @@ static bool load_template(private_guest_t *this, char *path) { char dir[PATH_MAX]; size_t len; - iface_t *iface; if (path == NULL) { @@ -324,10 +323,6 @@ static bool load_template(private_guest_t *this, char *path) { return FALSE; } - while (this->ifaces->remove_last(this->ifaces, (void**)&iface) == SUCCESS) - { - iface->destroy(iface); - } return TRUE; } diff --git a/src/dumm/guest.h b/src/dumm/guest.h index 19dc8a8bf..a1e4966ac 100644 --- a/src/dumm/guest.h +++ b/src/dumm/guest.h @@ -26,7 +26,7 @@ typedef struct guest_t guest_t; #include "iface.h" /** - * @brief State of a guest (started, stopped, ...) + * State of a guest (started, stopped, ...) */ enum guest_state_t { /** guest kernel not running at all */ @@ -68,33 +68,33 @@ typedef pid_t (*invoke_function_t)(void *data, guest_t *guest, typedef void (*idle_function_t)(void); /** - * @brief A guest is a UML instance running on the host. + * A guest is a UML instance running on the host. **/ struct guest_t { /** - * @brief Get the name of this guest. + * Get the name of this guest. * * @return name of the guest */ char* (*get_name) (guest_t *this); /** - * @brief Get the process ID of the guest child process. + * Get the process ID of the guest child process. * * @return name of the guest */ pid_t (*get_pid) (guest_t *this); /** - * @brief Get the state of the guest (stopped, started, etc.). + * Get the state of the guest (stopped, started, etc.). * * @return guests state */ guest_state_t (*get_state)(guest_t *this); /** - * @brief Start the guest. + * Start the guest. * * @param invoke UML guest invocation function * @param data data to pass back to invoke function @@ -105,14 +105,14 @@ struct guest_t { idle_function_t idle); /** - * @brief Kill the guest. + * Kill the guest. * * @param idle idle function to call while waiting to termination */ void (*stop) (guest_t *this, idle_function_t idle); /** - * @brief Create a new interface in the current scenario. + * Create a new interface in the current scenario. * * @param name name of the interface in the guest * @return created interface, or NULL if failed @@ -120,21 +120,21 @@ struct guest_t { iface_t* (*create_iface)(guest_t *this, char *name); /** - * @brief Destroy an interface on guest. + * Destroy an interface on guest. * * @param iface interface to destroy */ void (*destroy_iface)(guest_t *this, iface_t *iface); /** - * @brief Create an enumerator over all guest interfaces. + * Create an enumerator over all guest interfaces. * * @return enumerator over iface_t's */ enumerator_t* (*create_iface_enumerator)(guest_t *this); /** - * @brief Set the template COWFS overlay to use. + * Set the template COWFS overlay to use. * * @param parent parent directory where template diff should point to * @return FALSE if failed @@ -172,18 +172,18 @@ struct guest_t { void *data, char *cmd, ...); /** - * @brief Called whenever a SIGCHILD for the guests PID is received. + * Called whenever a SIGCHILD for the guests PID is received. */ void (*sigchild)(guest_t *this); /** - * @brief Close and destroy a guest with all interfaces + * Close and destroy a guest with all interfaces */ void (*destroy) (guest_t *this); }; /** - * @brief Create a new, unstarted guest. + * Create a new, unstarted guest. * * @param parent parent directory to create the guest in * @param name name of the guest to create @@ -196,7 +196,7 @@ guest_t *guest_create(char *parent, char *name, char *kernel, char *master, char *args); /** - * @brief Load a guest created with guest_create(). + * Load a guest created with guest_create(). * * @param parent parent directory to look for a guest * @param name name of the guest directory diff --git a/src/dumm/iface.h b/src/dumm/iface.h index 54a0554c0..7aef95c01 100644 --- a/src/dumm/iface.h +++ b/src/dumm/iface.h @@ -29,19 +29,19 @@ typedef struct iface_t iface_t; #include "guest.h" /** - * @brief Interface in a guest, connected to a tap device on the host. + * Interface in a guest, connected to a tap device on the host. */ struct iface_t { /** - * @brief Get the interface name in the guest (e.g. eth0). + * Get the interface name in the guest (e.g. eth0). * * @return guest interface name */ char* (*get_guestif)(iface_t *this); /** - * @brief Get the interface name at the host (e.g. tap0). + * Get the interface name at the host (e.g. tap0). * * @return host interface (tap device) name */ @@ -71,34 +71,34 @@ struct iface_t { bool (*delete_address)(iface_t *this, host_t *addr); /** - * @brief Set the bridge this interface is attached to. + * Set the bridge this interface is attached to. * * @param bridge assigned bridge, or NULL for none */ void (*set_bridge)(iface_t *this, bridge_t *bridge); /** - * @brief Get the bridge this iface is connected, or NULL. + * Get the bridge this iface is connected, or NULL. * * @return connected bridge, or NULL */ bridge_t* (*get_bridge)(iface_t *this); /** - * @brief Get the guest this iface belongs to. + * Get the guest this iface belongs to. * * @return guest of this iface */ guest_t* (*get_guest)(iface_t *this); /** - * @brief Destroy an interface + * Destroy an interface */ void (*destroy) (iface_t *this); }; /** - * @brief Create a new interface for a guest + * Create a new interface for a guest * * @param name name of the interface in the guest * @param guest guest this iface is connecting diff --git a/src/dumm/mconsole.c b/src/dumm/mconsole.c index 02db5ab7e..72d6d1b5e 100644 --- a/src/dumm/mconsole.c +++ b/src/dumm/mconsole.c @@ -147,8 +147,11 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t), } else if (reply.err) { - DBG1("received mconsole error %d: %*.s", - reply.err, reply.len, reply.data); + if (reply.len && *reply.data) + { + DBG1("received mconsole error %d: %*.s", + reply.err, reply.len, reply.data); + } break; } } diff --git a/src/dumm/mconsole.h b/src/dumm/mconsole.h index e8493b5bb..a4d93e48e 100644 --- a/src/dumm/mconsole.h +++ b/src/dumm/mconsole.h @@ -21,12 +21,12 @@ typedef struct mconsole_t mconsole_t; /** - * @brief UML mconsole, change running UML configuration using mconsole. + * UML mconsole, change running UML configuration using mconsole. */ struct mconsole_t { /** - * @brief Create a guest interface and connect it to tap host interface. + * Create a guest interface and connect it to tap host interface. * * @param guest name of the interface to create in the guest * @param host name of the tap device to connect guest to @@ -35,7 +35,7 @@ struct mconsole_t { bool (*add_iface)(mconsole_t *this, char *guest, char *host); /** - * @brief Delete a guest interface. + * Delete a guest interface. * * @param guest name of the interface to delete on the guest * @return TRUE if interface deleted @@ -54,13 +54,13 @@ struct mconsole_t { char *cmd); /** - * @brief Destroy the mconsole instance + * Destroy the mconsole instance */ void (*destroy) (mconsole_t *this); }; /** - * @brief Create a new mconsole connection to a guest. + * Create a new mconsole connection to a guest. * * Waits for a notification from the guest through the notify socket and tries * to connect to the mconsole socket supplied in the received notification. |