diff options
Diffstat (limited to 'src/dumm')
-rw-r--r-- | src/dumm/Makefile.in | 199 | ||||
-rw-r--r-- | src/dumm/bridge.c | 6 | ||||
-rw-r--r-- | src/dumm/bridge.h | 12 | ||||
-rw-r--r-- | src/dumm/cowfs.c | 115 | ||||
-rw-r--r-- | src/dumm/cowfs.h | 4 | ||||
-rw-r--r-- | src/dumm/dumm.c | 44 | ||||
-rw-r--r-- | src/dumm/dumm.h | 18 | ||||
-rw-r--r-- | src/dumm/ext/dumm.c | 93 | ||||
-rw-r--r-- | src/dumm/guest.c | 76 | ||||
-rw-r--r-- | src/dumm/guest.h | 40 | ||||
-rw-r--r-- | src/dumm/iface.c | 18 | ||||
-rw-r--r-- | src/dumm/iface.h | 20 | ||||
-rw-r--r-- | src/dumm/irdumm.c | 8 | ||||
-rw-r--r-- | src/dumm/main.c | 134 | ||||
-rw-r--r-- | src/dumm/mconsole.c | 42 | ||||
-rw-r--r-- | src/dumm/mconsole.h | 8 |
16 files changed, 456 insertions, 381 deletions
diff --git a/src/dumm/Makefile.in b/src/dumm/Makefile.in index 817e31104..8bc08e2c1 100644 --- a/src/dumm/Makefile.in +++ b/src/dumm/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.10.2 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -17,8 +18,9 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c @@ -37,26 +39,47 @@ ipsec_PROGRAMS = dumm$(EXEEXT) irdumm$(EXEEXT) subdir = src/dumm DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \ + $(top_srcdir)/m4/config/ltoptions.m4 \ + $(top_srcdir)/m4/config/ltsugar.m4 \ + $(top_srcdir)/m4/config/ltversion.m4 \ + $(top_srcdir)/m4/config/lt~obsolete.m4 \ + $(top_srcdir)/m4/macros/with.m4 \ + $(top_srcdir)/m4/macros/enable-disable.m4 \ + $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(ipsecdir)" -libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libdumm_la_DEPENDENCIES = \ $(top_builddir)/src/libstrongswan/libstrongswan.la am_libdumm_la_OBJECTS = dumm.lo guest.lo iface.lo bridge.lo \ mconsole.lo cowfs.lo libdumm_la_OBJECTS = $(am_libdumm_la_OBJECTS) -ipsecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(ipsec_PROGRAMS) am_dumm_OBJECTS = main.$(OBJEXT) dumm_OBJECTS = $(am_dumm_OBJECTS) @@ -68,6 +91,7 @@ irdumm_DEPENDENCIES = libdumm.la DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -115,25 +139,22 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -IPSEC_ROUTING_TABLE = @IPSEC_ROUTING_TABLE@ -IPSEC_ROUTING_TABLE_PRIO = @IPSEC_ROUTING_TABLE_PRIO@ LD = @LD@ 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@ -LINUX_HEADERS = @LINUX_HEADERS@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MYSQLCFLAG = @MYSQLCFLAG@ +MYSQLCONFIG = @MYSQLCONFIG@ +MYSQLLIB = @MYSQLLIB@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ @@ -145,11 +166,14 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ +PTHREADLIB = @PTHREADLIB@ RANLIB = @RANLIB@ +RTLIB = @RTLIB@ RUBY = @RUBY@ RUBYINCLUDE = @RUBYINCLUDE@ SED = @SED@ @@ -178,9 +202,9 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -confdir = @confdir@ datadir = @datadir@ datarootdir = @datarootdir@ +default_pkcs11 = @default_pkcs11@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ @@ -203,7 +227,7 @@ ipsecuser = @ipsecuser@ libdir = @libdir@ libexecdir = @libexecdir@ libstrongswan_plugins = @libstrongswan_plugins@ -linuxdir = @linuxdir@ +linux_headers = @linux_headers@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ @@ -211,6 +235,7 @@ mandir = @mandir@ mkdir_p = @mkdir_p@ nm_CFLAGS = @nm_CFLAGS@ nm_LIBS = @nm_LIBS@ +nm_ca_dir = @nm_ca_dir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ piddir = @piddir@ @@ -219,10 +244,12 @@ pluto_plugins = @pluto_plugins@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +random_device = @random_device@ resolv_conf = @resolv_conf@ +routing_table = @routing_table@ +routing_table_prio = @routing_table_prio@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ -simreader = @simreader@ srcdir = @srcdir@ strongswan_conf = @strongswan_conf@ sysconfdir = @sysconfdir@ @@ -230,6 +257,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +urandom_device = @urandom_device@ xml_CFLAGS = @xml_CFLAGS@ xml_LIBS = @xml_LIBS@ EXTRA_DIST = ext/dumm.c ext/README \ @@ -263,9 +291,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dumm/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/dumm/Makefile + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dumm/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/dumm/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -283,23 +311,28 @@ $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ if test -f $$p; then \ - f=$(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + list2="$$list2 $$p"; \ else :; fi; \ - done + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p=$(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: @@ -315,31 +348,46 @@ libdumm.la: $(libdumm_la_OBJECTS) $(libdumm_la_DEPENDENCIES) install-ipsecPROGRAMS: $(ipsec_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(ipsecdir)" || $(MKDIR_P) "$(DESTDIR)$(ipsecdir)" - @list='$(ipsec_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - || test -f $$p1 \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(ipsecPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(ipsecdir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(ipsecPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(ipsecdir)/$$f" || exit 1; \ - else :; fi; \ - done + @list='$(ipsec_PROGRAMS)'; test -n "$(ipsecdir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(ipsecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(ipsecdir)$$dir" || exit $$?; \ + } \ + ; done uninstall-ipsecPROGRAMS: @$(NORMAL_UNINSTALL) - @list='$(ipsec_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(ipsecdir)/$$f'"; \ - rm -f "$(DESTDIR)$(ipsecdir)/$$f"; \ - done + @list='$(ipsec_PROGRAMS)'; test -n "$(ipsecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(ipsecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(ipsecdir)" && rm -f $$files clean-ipsecPROGRAMS: - @list='$(ipsec_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done + @list='$(ipsec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list dumm$(EXEEXT): $(dumm_OBJECTS) $(dumm_DEPENDENCIES) @rm -f dumm$(EXEEXT) $(LINK) $(dumm_OBJECTS) $(dumm_LDADD) $(LIBS) @@ -364,21 +412,21 @@ distclean-compile: .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< @@ -401,7 +449,7 @@ tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ + set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -409,29 +457,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) - tags=; \ list='$(SOURCES) $(HEADERS) $(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; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ + test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique + $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -452,13 +505,17 @@ distdir: $(DISTFILES) if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @@ -489,6 +546,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -510,6 +568,8 @@ dvi-am: html: html-am +html-am: + info: info-am info-am: @@ -518,18 +578,28 @@ install-data-am: install-data-local install-ipsecPROGRAMS install-dvi: install-dvi-am +install-dvi-am: + install-exec-am: install-libLTLIBRARIES install-html: install-html-am +install-html-am: + install-info: install-info-am +install-info-am: + install-man: install-pdf: install-pdf-am +install-pdf-am: + install-ps: install-ps-am +install-ps-am: + installcheck-am: maintainer-clean: maintainer-clean-am @@ -583,6 +653,7 @@ 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.c b/src/dumm/bridge.c index 209e54fc1..592fecefd 100644 --- a/src/dumm/bridge.c +++ b/src/dumm/bridge.c @@ -36,7 +36,7 @@ struct private_bridge_t { * defined in iface.c */ bool iface_control(char *name, bool up); - + /** * Implementation of bridge_t.get_name. */ @@ -149,7 +149,7 @@ static void destroy(private_bridge_t *this) bridge_t *bridge_create(char *name) { private_bridge_t *this; - + if (instances == 0) { if (br_init() != 0) @@ -158,7 +158,7 @@ bridge_t *bridge_create(char *name) return NULL; } } - + this = malloc_thing(private_bridge_t); this->public.get_name = (char*(*)(bridge_t*))get_name; this->public.create_iface_enumerator = (enumerator_t*(*)(bridge_t*))create_iface_enumerator; diff --git a/src/dumm/bridge.h b/src/dumm/bridge.h index 37b22a03e..c557de994 100644 --- a/src/dumm/bridge.h +++ b/src/dumm/bridge.h @@ -27,14 +27,14 @@ typedef struct bridge_t bridge_t; * Interface in a guest, connected to a tap device on the host. */ struct bridge_t { - + /** * Get the name of the bridge. * * @return name of the bridge */ char* (*get_name)(bridge_t *this); - + /** * Add an interface to a bridge. * @@ -42,7 +42,7 @@ struct bridge_t { * @return TRUE if interface added */ bool (*connect_iface)(bridge_t *this, iface_t *iface); - + /** * Remove an interface from a bridge. * @@ -50,14 +50,14 @@ struct bridge_t { * @return TRUE if interface removed */ bool (*disconnect_iface)(bridge_t *this, iface_t *iface); - + /** * Create an enumerator over all interfaces. * * @return enumerator over iface_t's */ - enumerator_t* (*create_iface_enumerator)(bridge_t *this); - + enumerator_t* (*create_iface_enumerator)(bridge_t *this); + /** * Destroy a bridge */ diff --git a/src/dumm/cowfs.c b/src/dumm/cowfs.c index 69f008976..f7b6b0cf3 100644 --- a/src/dumm/cowfs.c +++ b/src/dumm/cowfs.c @@ -29,12 +29,12 @@ #include <dirent.h> #include <errno.h> #include <sys/time.h> -#include <pthread.h> #include "cowfs.h" #include <library.h> #include <debug.h> +#include <threading/thread.h> /** define _XOPEN_SOURCE 500 fails when using libstrongswan, define popen */ extern ssize_t pread(int fd, void *buf, size_t count, off_t offset); @@ -64,7 +64,7 @@ struct private_cowfs_t { /** optional COW overlay */ int over_fd; /** thread processing FUSE */ - pthread_t thread; + thread_t *thread; }; /** @@ -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; @@ -130,7 +130,7 @@ static bool clone_path(int rd, int wr, const char *path) struct stat st; full = strdupa(path); pos = full; - + while ((pos = strchr(pos, '/'))) { *pos = '\0'; @@ -162,10 +162,10 @@ static int copy(const char *path) int rd, wr; int from, to; struct stat st; - + rd = get_rd(path); wr = get_wr(path); - + if (rd == wr) { /* already writeable */ @@ -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; @@ -237,7 +237,7 @@ static int cowfs_getattr(const char *path, struct stat *stbuf) static int cowfs_access(const char *path, int mask) { rel(&path); - + if (faccessat(get_rd(path), path, mask, 0) < 0) { return -errno; @@ -251,9 +251,9 @@ 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) { @@ -269,16 +269,16 @@ static int cowfs_readlink(const char *path, char *buf, size_t size) static DIR* get_dir(char *dir, const char *subdir) { char *full; - + if (dir == NULL) { return NULL; } - + full = alloca(strlen(dir) + strlen(subdir) + 1); strcpy(full, dir); strcat(full, subdir); - + return opendir(full); } @@ -290,7 +290,7 @@ static bool contains_dir(DIR *d, char *dirname) if (d) { struct dirent *ent; - + rewinddir(d); while ((ent = readdir(d))) { @@ -313,13 +313,13 @@ static int cowfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, DIR *d1, *d2, *d3; struct stat st; struct dirent *ent; - + memset(&st, 0, sizeof(st)); - + d1 = get_dir(this->master, path); d2 = get_dir(this->host, path); d3 = get_dir(this->over, path); - + if (d1) { while ((ent = readdir(d1))) @@ -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)) { @@ -409,7 +409,7 @@ static int cowfs_mkdir(const char *path, mode_t mode) static int cowfs_unlink(const char *path) { rel(&path); - + /* TODO: whiteout master */ if (unlinkat(get_wr(path), path, 0) < 0) { @@ -424,7 +424,7 @@ static int cowfs_unlink(const char *path) static int cowfs_rmdir(const char *path) { rel(&path); - + /* TODO: whiteout master */ if (unlinkat(get_wr(path), path, AT_REMOVEDIR) < 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,10 +462,10 @@ static int cowfs_symlink(const char *from, const char *to) static int cowfs_rename(const char *from, const char *to) { int fd; - + rel(&from); rel(&to); - + fd = copy(from); if (fd < 0) { @@ -484,13 +484,13 @@ 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); - + rd = get_rd(from); wr = get_wr(to); - + if (!clone_path(rd, wr, to)) { DBG1("cloning path '%s' failed", to); @@ -511,7 +511,7 @@ static int cowfs_chmod(const char *path, mode_t mode) { int fd; struct stat st; - + rel(&path); fd = get_rd(path); if (fstatat(fd, path, &st, 0) < 0) @@ -541,7 +541,7 @@ static int cowfs_chown(const char *path, uid_t uid, gid_t gid) { int fd; struct stat st; - + rel(&path); fd = get_rd(path); if (fstatat(fd, path, &st, 0) < 0) @@ -571,7 +571,7 @@ static int cowfs_truncate(const char *path, off_t size) { int fd; struct stat st; - + rel(&path); fd = get_rd(path); if (fstatat(fd, path, &st, 0) < 0) @@ -608,19 +608,19 @@ static int cowfs_utimens(const char *path, const struct timespec ts[2]) { struct timeval tv[2]; int fd; - + rel(&path); fd = copy(path); if (fd < 0) { 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; @@ -634,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) { @@ -654,17 +654,17 @@ 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) { return -errno; } - + res = pread(file, buf, size, offset); if (res < 0) { @@ -681,9 +681,9 @@ static int cowfs_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int file, fd, res; - + rel(&path); - + fd = copy(path); if (fd < 0) { @@ -709,25 +709,25 @@ static int cowfs_write(const char *path, const char *buf, size_t size, static int cowfs_statfs(const char *path, struct statvfs *stbuf) { int fd; - + fd = get_rd(path); if (fstatvfs(fd, stbuf) < 0) { return -errno; } - + return 0; } -/** +/** * FUSE init method */ static void *cowfs_init(struct fuse_conn_info *conn) { struct fuse_context *ctx; - + ctx = fuse_get_context(); - + return ctx->private_data; } @@ -792,7 +792,7 @@ static void destroy(private_cowfs_t *this) { fuse_exit(this->fuse); fuse_unmount(this->mount, this->chan); - pthread_join(this->thread, NULL); + this->thread->join(this->thread); fuse_destroy(this->fuse); free(this->mount); free(this->master); @@ -814,10 +814,10 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) { struct fuse_args args = {0, NULL, 0}; private_cowfs_t *this = malloc_thing(private_cowfs_t); - + 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) { @@ -834,7 +834,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) return NULL; } this->over_fd = -1; - + this->chan = fuse_mount(mount, &args); if (this->chan == NULL) { @@ -844,7 +844,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) free(this); return NULL; } - + this->fuse = fuse_new(this->chan, &args, &cowfs_operations, sizeof(cowfs_operations), this); if (this->fuse == NULL) @@ -856,13 +856,14 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) 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) + + this->thread = thread_create((thread_main_t)fuse_loop, this->fuse); + if (!this->thread) { DBG1("creating thread to handle FUSE failed"); fuse_unmount(mount, this->chan); @@ -874,7 +875,7 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount) free(this); return NULL; } - + return &this->public; } diff --git a/src/dumm/cowfs.h b/src/dumm/cowfs.h index bb589f158..d430597a8 100644 --- a/src/dumm/cowfs.h +++ b/src/dumm/cowfs.h @@ -25,7 +25,7 @@ typedef struct cowfs_t cowfs_t; * */ struct cowfs_t { - + /** * Set an additional copy on write overlay. * @@ -33,7 +33,7 @@ struct cowfs_t { * @return FALSE if failed */ bool (*set_overlay)(cowfs_t *this, char *path); - + /** * Stop, umount and destroy a cowfs FUSE filesystem. */ diff --git a/src/dumm/dumm.c b/src/dumm/dumm.c index 2cb1235e1..0e8ab43f3 100644 --- a/src/dumm/dumm.c +++ b/src/dumm/dumm.c @@ -52,11 +52,11 @@ struct private_dumm_t { /** * Implementation of dumm_t.create_guest. */ -static guest_t* create_guest(private_dumm_t *this, char *name, char *kernel, +static guest_t* create_guest(private_dumm_t *this, char *name, char *kernel, char *master, char *args) { guest_t *guest; - + guest = guest_create(this->guest_dir, name, kernel, master, args); if (guest) { @@ -82,7 +82,7 @@ static void delete_guest(private_dumm_t *this, guest_t *guest) { char buf[512]; int len; - + len = snprintf(buf, sizeof(buf), "rm -Rf %s/%s", this->guest_dir, guest->get_name(guest)); guest->destroy(guest); @@ -99,7 +99,7 @@ static void delete_guest(private_dumm_t *this, guest_t *guest) static bridge_t* create_bridge(private_dumm_t *this, char *name) { bridge_t *bridge; - + bridge = bridge_create(name); if (bridge) { @@ -128,16 +128,16 @@ static void delete_bridge(private_dumm_t *this, bridge_t *bridge) } /** - * disable the currently enabled template + * disable the currently enabled template */ 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)) { @@ -153,9 +153,9 @@ static bool load_template(private_dumm_t *this, char *dir) { enumerator_t *enumerator; guest_t *guest; - + clear_template(this); - + if (dir == NULL) { return TRUE; @@ -165,7 +165,7 @@ static bool load_template(private_dumm_t *this, char *dir) DBG1("template directory string '%s' is too long", dir); return FALSE; } - + if (asprintf(&this->template, "%s/%s", TEMPLATE_DIR, dir) < 0) { this->template = NULL; @@ -210,7 +210,7 @@ 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 != '.') @@ -237,12 +237,12 @@ static void template_enumerator_destroy(template_enumerator_t *this) 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; } @@ -253,16 +253,16 @@ 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); while (enumerator->enumerate(enumerator, (void**)&guest)) { guest->stop(guest, NULL); } enumerator->destroy(enumerator); - + while (this->guests->remove_last(this->guests, (void**)&guest) == SUCCESS) { guest->destroy(guest); @@ -282,13 +282,13 @@ static void load_guests(private_dumm_t *this) DIR *dir; struct dirent *ent; guest_t *guest; - + dir = opendir(this->guest_dir); if (dir == NULL) { return; } - + while ((ent = readdir(dir))) { if (*ent->d_name == '.') @@ -315,7 +315,7 @@ dumm_t *dumm_create(char *dir) { char cwd[PATH_MAX]; private_dumm_t *this = malloc_thing(private_dumm_t); - + this->public.create_guest = (guest_t*(*)(dumm_t*,char*,char*,char*,char*))create_guest; this->public.create_guest_enumerator = (enumerator_t*(*)(dumm_t*))create_guest_enumerator; this->public.delete_guest = (void(*)(dumm_t*,guest_t*))delete_guest; @@ -325,7 +325,7 @@ dumm_t *dumm_create(char *dir) 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 == '/') { this->dir = strdup(dir); @@ -356,7 +356,7 @@ dumm_t *dumm_create(char *dir) } this->guests = linked_list_create(); this->bridges = linked_list_create(); - + if (this->dir == NULL || this->guest_dir == NULL || (mkdir(this->guest_dir, PERME) < 0 && errno != EEXIST)) { @@ -364,7 +364,7 @@ dumm_t *dumm_create(char *dir) destroy(this); return NULL; } - + load_guests(this); return &this->public; } diff --git a/src/dumm/dumm.h b/src/dumm/dumm.h index 5f2e0542a..54c3fbc03 100644 --- a/src/dumm/dumm.h +++ b/src/dumm/dumm.h @@ -43,23 +43,23 @@ struct dumm_t { * @param args additional args to pass to kernel * @return guest if started, NULL if failed */ - guest_t* (*create_guest) (dumm_t *this, char *name, char *kernel, + guest_t* (*create_guest) (dumm_t *this, char *name, char *kernel, char *master, char *args); - + /** * Create an enumerator over all guests. * * @return enumerator over guest_t's */ enumerator_t* (*create_guest_enumerator) (dumm_t *this); - + /** * Delete a guest from disk. * * @param guest guest to destroy */ void (*delete_guest) (dumm_t *this, guest_t *guest); - + /** * Create a new bridge. * @@ -67,21 +67,21 @@ struct dumm_t { * @return created bridge */ bridge_t* (*create_bridge)(dumm_t *this, char *name); - + /** * Create an enumerator over all bridges. * * @return enumerator over bridge_t's */ enumerator_t* (*create_bridge_enumerator)(dumm_t *this); - + /** * Delete a bridge. * * @param bridge bridge to destroy */ void (*delete_bridge) (dumm_t *this, bridge_t *bridge); - + /** * Loads a template, create a new one if it does not exist. * @@ -89,14 +89,14 @@ struct dumm_t { * @return FALSE if load/create failed */ bool (*load_template)(dumm_t *this, char *dir); - + /** * 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 */ diff --git a/src/dumm/ext/dumm.c b/src/dumm/ext/dumm.c index f7caf252d..230e8ae68 100644 --- a/src/dumm/ext/dumm.c +++ b/src/dumm/ext/dumm.c @@ -29,6 +29,7 @@ #undef PACKAGE_VERSION #undef PACKAGE_STRING #undef PACKAGE_BUGREPORT +#undef PACKAGE_URL #include <ruby.h> static dumm_t *dumm; @@ -45,7 +46,7 @@ static VALUE rbc_template; static pid_t invoke(void *null, guest_t *guest, char *args[], int argc) { pid_t pid; - + pid = fork(); switch (pid) { @@ -71,7 +72,7 @@ static void sigchld_handler(int signal, siginfo_t *info, void* ptr) { enumerator_t *enumerator; guest_t *guest; - + enumerator = dumm->create_guest_enumerator(dumm); while (enumerator->enumerate(enumerator, &guest)) { @@ -91,7 +92,7 @@ static VALUE guest_find(VALUE class, VALUE key) { enumerator_t *enumerator; guest_t *guest, *found = NULL; - + if (TYPE(key) == T_SYMBOL) { key = rb_convert_type(key, T_STRING, "String", "to_s"); @@ -128,7 +129,7 @@ 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"); @@ -152,7 +153,7 @@ static VALUE guest_new(VALUE class, VALUE name, VALUE kernel, VALUE master, VALUE args) { guest_t *guest; - + guest = dumm->create_guest(dumm, StringValuePtr(name), StringValuePtr(kernel), StringValuePtr(master), StringValuePtr(args)); if (!guest) @@ -165,7 +166,7 @@ static VALUE guest_new(VALUE class, VALUE name, VALUE kernel, static VALUE guest_to_s(VALUE self) { guest_t *guest; - + Data_Get_Struct(self, guest_t, guest); return rb_str_new2(guest->get_name(guest)); } @@ -173,9 +174,9 @@ static VALUE guest_to_s(VALUE self) static VALUE guest_start(VALUE self) { guest_t *guest; - + Data_Get_Struct(self, guest_t, guest); - + if (!guest->start(guest, invoke, NULL, NULL)) { rb_raise(rb_eRuntimeError, "starting guest failed"); @@ -186,7 +187,7 @@ static VALUE guest_start(VALUE self) static VALUE guest_stop(VALUE self) { guest_t *guest; - + Data_Get_Struct(self, guest_t, guest); guest->stop(guest, NULL); return self; @@ -195,7 +196,7 @@ static VALUE guest_stop(VALUE self) static VALUE guest_running(VALUE self) { guest_t *guest; - + Data_Get_Struct(self, guest_t, guest); return guest->get_pid(guest) ? Qtrue : Qfalse; } @@ -210,7 +211,7 @@ static VALUE guest_exec(VALUE self, VALUE cmd) guest_t *guest; bool block; int ret; - + block = rb_block_given_p(); Data_Get_Struct(self, guest_t, guest); if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL, @@ -226,7 +227,7 @@ static VALUE guest_mconsole(VALUE self, VALUE cmd) guest_t *guest; bool block; int ret; - + block = rb_block_given_p(); Data_Get_Struct(self, guest_t, guest); if ((ret = guest->exec_str(guest, block ? (void*)exec_cb : NULL, TRUE, NULL, @@ -241,7 +242,7 @@ static VALUE guest_add_iface(VALUE self, VALUE name) { guest_t *guest; iface_t *iface; - + Data_Get_Struct(self, guest_t, guest); iface = guest->create_iface(guest, StringValuePtr(name)); if (!iface) @@ -256,7 +257,7 @@ 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) { key = rb_convert_type(key, T_STRING, "String", "to_s"); @@ -295,7 +296,7 @@ static VALUE guest_each_iface(int argc, VALUE *argv, VALUE self) 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"); @@ -319,7 +320,7 @@ static VALUE guest_each_iface(int argc, VALUE *argv, VALUE self) static VALUE guest_delete(VALUE self) { guest_t *guest; - + Data_Get_Struct(self, guest_t, guest); if (guest->get_pid(guest)) { @@ -334,13 +335,13 @@ static void guest_init() rbc_guest = rb_define_class_under(rbm_dumm , "Guest", rb_cObject); rb_include_module(rb_class_of(rbc_guest), rb_mEnumerable); rb_include_module(rbc_guest, rb_mEnumerable); - + rb_define_singleton_method(rbc_guest, "[]", guest_get, 1); rb_define_singleton_method(rbc_guest, "each", guest_each, -1); rb_define_singleton_method(rbc_guest, "new", guest_new, 4); rb_define_singleton_method(rbc_guest, "include?", guest_find, 1); rb_define_singleton_method(rbc_guest, "guest?", guest_find, 1); - + rb_define_method(rbc_guest, "to_s", guest_to_s, 0); rb_define_method(rbc_guest, "start", guest_start, 0); rb_define_method(rbc_guest, "stop", guest_stop, 0); @@ -362,7 +363,7 @@ 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"); @@ -399,7 +400,7 @@ 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"); @@ -423,7 +424,7 @@ static VALUE bridge_new(VALUE class, VALUE name) { bridge_t *bridge; - + bridge = dumm->create_bridge(dumm, StringValuePtr(name)); if (!bridge) { @@ -435,7 +436,7 @@ static VALUE bridge_new(VALUE class, VALUE name) static VALUE bridge_to_s(VALUE self) { bridge_t *bridge; - + Data_Get_Struct(self, bridge_t, bridge); return rb_str_new2(bridge->get_name(bridge)); } @@ -446,7 +447,7 @@ static VALUE bridge_each_iface(int argc, VALUE *argv, VALUE self) 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"); @@ -470,7 +471,7 @@ static VALUE bridge_each_iface(int argc, VALUE *argv, VALUE self) static VALUE bridge_delete(VALUE self) { bridge_t *bridge; - + Data_Get_Struct(self, bridge_t, bridge); dumm->delete_bridge(dumm, bridge); return Qnil; @@ -481,13 +482,13 @@ static void bridge_init() rbc_bridge = rb_define_class_under(rbm_dumm , "Bridge", rb_cObject); rb_include_module(rb_class_of(rbc_bridge), rb_mEnumerable); rb_include_module(rbc_bridge, rb_mEnumerable); - + 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); rb_define_method(rbc_bridge, "delete", bridge_delete, 0); @@ -499,7 +500,7 @@ static void bridge_init() static VALUE iface_to_s(VALUE self) { iface_t *iface; - + Data_Get_Struct(self, iface_t, iface); return rb_str_new2(iface->get_hostif(iface)); } @@ -508,7 +509,7 @@ static VALUE iface_connect(VALUE self, VALUE vbridge) { iface_t *iface; bridge_t *bridge; - + Data_Get_Struct(self, iface_t, iface); Data_Get_Struct(vbridge, bridge_t, bridge); if (!bridge->connect_iface(bridge, iface)) @@ -522,7 +523,7 @@ static VALUE iface_disconnect(VALUE self) { iface_t *iface; bridge_t *bridge; - + Data_Get_Struct(self, iface_t, iface); bridge = iface->get_bridge(iface); if (!bridge || !bridge->disconnect_iface(bridge, iface)) @@ -536,7 +537,7 @@ static VALUE iface_add_addr(VALUE self, VALUE name) { iface_t *iface; host_t *addr; - + addr = host_create_from_string(StringValuePtr(name), 0); if (!addr) { @@ -563,7 +564,7 @@ static VALUE iface_each_addr(int argc, VALUE *argv, VALUE self) iface_t *iface; host_t *addr; char buf[64]; - + if (!rb_block_given_p()) { rb_raise(rb_eArgError, "must be called with a block"); @@ -589,7 +590,7 @@ static VALUE iface_del_addr(VALUE self, VALUE vaddr) { iface_t *iface; host_t *addr; - + addr = host_create_from_string(StringValuePtr(vaddr), 0); if (!addr) { @@ -613,7 +614,7 @@ static VALUE iface_delete(VALUE self) { guest_t *guest; iface_t *iface; - + Data_Get_Struct(self, iface_t, iface); guest = iface->get_guest(iface); guest->destroy_iface(guest, iface); @@ -624,7 +625,7 @@ static void iface_init() { rbc_iface = rb_define_class_under(rbm_dumm , "Iface", rb_cObject); rb_include_module(rbc_iface, rb_mEnumerable); - + rb_define_method(rbc_iface, "to_s", iface_to_s, 0); rb_define_method(rbc_iface, "connect", iface_connect, 1); rb_define_method(rbc_iface, "disconnect", iface_disconnect, 0); @@ -656,7 +657,7 @@ 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"); @@ -673,7 +674,7 @@ static VALUE template_each(int argc, VALUE *argv, VALUE 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); @@ -685,14 +686,14 @@ static void template_init() void Final_dumm() { struct sigaction action; - + dumm->destroy(dumm); - + sigemptyset(&action.sa_mask); action.sa_handler = SIG_DFL; action.sa_flags = 0; sigaction(SIGCHLD, &action, NULL); - + library_deinit(); } @@ -702,25 +703,25 @@ void Final_dumm() void Init_dumm() { struct sigaction action; - + /* there are too many to report, rubyruby... */ setenv("LEAK_DETECTIVE_DISABLE", "1", 1); - + library_init(NULL); - + dumm = dumm_create(NULL); - + rbm_dumm = rb_define_module("Dumm"); - + guest_init(); bridge_init(); iface_init(); template_init(); - + sigemptyset(&action.sa_mask); action.sa_sigaction = sigchld_handler; action.sa_flags = SA_SIGINFO; sigaction(SIGCHLD, &action, NULL); - + rb_set_end_proc(Final_dumm, 0); } diff --git a/src/dumm/guest.c b/src/dumm/guest.c index 969a2a99d..112adb441 100644 --- a/src/dumm/guest.c +++ b/src/dumm/guest.c @@ -97,13 +97,13 @@ static iface_t* create_iface(private_guest_t *this, char *name) { enumerator_t *enumerator; iface_t *iface; - + if (this->state != GUEST_RUNNING) { DBG1("guest '%s' not running, unable to add interface", this->name); return NULL; } - + enumerator = this->ifaces->create_enumerator(this->ifaces); while (enumerator->enumerate(enumerator, (void**)&iface)) { @@ -131,7 +131,7 @@ static void destroy_iface(private_guest_t *this, iface_t *iface) { enumerator_t *enumerator; iface_t *current; - + enumerator = this->ifaces->create_enumerator(this->ifaces); while (enumerator->enumerate(enumerator, (void**)¤t)) { @@ -152,7 +152,7 @@ static enumerator_t* create_iface_enumerator(private_guest_t *this) { return this->ifaces->create_enumerator(this->ifaces); } - + /** * Implementation of guest_t.get_state. */ @@ -224,7 +224,7 @@ static void stop(private_guest_t *this, idle_function_t idle) void savepid(private_guest_t *this) { FILE *file; - + file = fdopen(openat(this->dir, PID_FILE, O_RDWR | O_CREAT | O_TRUNC, PERM), "w"); if (file) @@ -246,18 +246,18 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data, char *args[32]; int i = 0; size_t left = sizeof(buf); - + memset(args, 0, sizeof(args)); - + if (this->state != GUEST_STOPPED) { DBG1("unable to start guest in state %N", guest_state_names, this->state); return FALSE; } this->state = GUEST_STARTING; - + notify = write_arg(&pos, &left, "%s/%s", this->dirname, NOTIFY_FILE); - + args[i++] = write_arg(&pos, &left, "nice"); args[i++] = write_arg(&pos, &left, "%s/%s", this->dirname, KERNEL_FILE); args[i++] = write_arg(&pos, &left, "root=/dev/root"); @@ -271,7 +271,7 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data, { args[i++] = this->args; } - + this->pid = invoke(data, &this->public, args, i); if (!this->pid) { @@ -279,7 +279,7 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data, return FALSE; } savepid(this); - + /* open mconsole */ this->mconsole = mconsole_create(notify, idle); if (this->mconsole == NULL) @@ -288,11 +288,11 @@ static bool start(private_guest_t *this, invoke_function_t invoke, void* data, stop(this, NULL); return FALSE; } - + this->state = GUEST_RUNNING; return TRUE; -} - +} + /** * Implementation of guest_t.load_template. */ @@ -300,12 +300,12 @@ static bool load_template(private_guest_t *this, char *path) { char dir[PATH_MAX]; size_t len; - + if (path == NULL) { - return this->cowfs->set_overlay(this->cowfs, NULL); + return this->cowfs->set_overlay(this->cowfs, NULL); } - + len = snprintf(dir, sizeof(dir), "%s/%s", path, this->name); if (len < 0 || len >= sizeof(dir)) { @@ -334,11 +334,11 @@ static int vexec(private_guest_t *this, void(*cb)(void*,char*,size_t), void *dat { char buf[1024]; size_t len; - + if (this->mconsole) { len = vsnprintf(buf, sizeof(buf), cmd, args); - + if (len > 0 && len < sizeof(buf)) { return this->mconsole->exec(this->mconsole, cb, data, buf); @@ -389,7 +389,7 @@ static void exec_str_cb(exec_str_t *data, char *buf, size_t len) } strncat(data->buf.ptr, buf, len); } - + if (data->cb) { char *nl; @@ -477,7 +477,7 @@ static bool mount_unionfs(private_guest_t *this) snprintf(master, sizeof(master), "%s/%s", this->dirname, MASTER_DIR); snprintf(diff, sizeof(diff), "%s/%s", this->dirname, DIFF_DIR); snprintf(mount, sizeof(mount), "%s/%s", this->dirname, UNION_DIR); - + this->cowfs = cowfs_create(master, diff, mount); if (this->cowfs) { @@ -494,7 +494,7 @@ char *loadargs(private_guest_t *this) { FILE *file; char buf[512], *args = NULL; - + file = fdopen(openat(this->dir, ARGS_FILE, O_RDONLY, PERM), "r"); if (file) { @@ -514,7 +514,7 @@ bool saveargs(private_guest_t *this, char *args) { FILE *file; bool retval = FALSE; - + file = fdopen(openat(this->dir, ARGS_FILE, O_RDWR | O_CREAT | O_TRUNC, PERM), "w"); if (file) @@ -554,7 +554,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name, { char cwd[PATH_MAX]; private_guest_t *this = malloc_thing(private_guest_t); - + this->public.get_name = (void*)get_name; this->public.get_pid = (pid_t(*)(guest_t*))get_pid; this->public.get_state = (guest_state_t(*)(guest_t*))get_state; @@ -568,7 +568,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name, this->public.exec_str = (int(*)(guest_t*, void(*cb)(void*,char*),bool,void*,char*,...))exec_str; this->public.sigchild = (void(*)(guest_t*))sigchild; this->public.destroy = (void*)destroy; - + if (*parent == '/' || getcwd(cwd, sizeof(cwd)) == NULL) { if (asprintf(&this->dirname, "%s/%s", parent, name) < 0) @@ -607,7 +607,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name, this->args = NULL; this->name = strdup(name); this->cowfs = NULL; - + return this; } @@ -618,7 +618,7 @@ static bool make_symlink(private_guest_t *this, char *old, char *new) { char cwd[PATH_MAX]; char buf[PATH_MAX]; - + if (*old == '/' || getcwd(cwd, sizeof(cwd)) == NULL) { snprintf(buf, sizeof(buf), "%s", old); @@ -632,18 +632,18 @@ static bool make_symlink(private_guest_t *this, char *old, char *new) /** - * create the guest instance, including required dirs and mounts + * create the guest instance, including required dirs and mounts */ guest_t *guest_create(char *parent, char *name, char *kernel, char *master, char *args) { private_guest_t *this = guest_create_generic(parent, name, TRUE); - + if (this == NULL) { return NULL; } - + if (!make_symlink(this, master, MASTER_DIR) || !make_symlink(this, kernel, KERNEL_FILE)) { @@ -651,22 +651,22 @@ guest_t *guest_create(char *parent, char *name, char *kernel, destroy(this); return NULL; } - - if (mkdirat(this->dir, UNION_DIR, PERME) != 0 || + + if (mkdirat(this->dir, UNION_DIR, PERME) != 0 || mkdirat(this->dir, DIFF_DIR, PERME) != 0) { DBG1("unable to create directories for '%s': %m", name); destroy(this); return NULL; } - + this->args = args; if (args && !saveargs(this, args)) { destroy(this); return NULL; } - + if (!mount_unionfs(this)) { destroy(this); @@ -682,20 +682,20 @@ guest_t *guest_create(char *parent, char *name, char *kernel, guest_t *guest_load(char *parent, char *name) { private_guest_t *this = guest_create_generic(parent, name, FALSE); - + if (this == NULL) { return NULL; } - + this->args = loadargs(this); - + if (!mount_unionfs(this)) { destroy(this); return NULL; } - + return &this->public; } diff --git a/src/dumm/guest.h b/src/dumm/guest.h index a1e4966ac..5f812f8eb 100644 --- a/src/dumm/guest.h +++ b/src/dumm/guest.h @@ -56,10 +56,10 @@ extern enum_name_t *guest_state_names; * @param guest guest to start * @param args args to use for guest invocation, args[0] is kernel * @param argc number of elements in args - * @param idle + * @param idle * @return PID of child, 0 if failed */ -typedef pid_t (*invoke_function_t)(void *data, guest_t *guest, +typedef pid_t (*invoke_function_t)(void *data, guest_t *guest, char *args[], int argc); /** @@ -71,28 +71,28 @@ typedef void (*idle_function_t)(void); * A guest is a UML instance running on the host. **/ struct guest_t { - + /** * Get the name of this guest. * * @return name of the guest */ char* (*get_name) (guest_t *this); - + /** * Get the process ID of the guest child process. * * @return name of the guest */ pid_t (*get_pid) (guest_t *this); - + /** * Get the state of the guest (stopped, started, etc.). * * @return guests state */ - guest_state_t (*get_state)(guest_t *this); - + guest_state_t (*get_state)(guest_t *this); + /** * Start the guest. * @@ -103,14 +103,14 @@ struct guest_t { */ bool (*start) (guest_t *this, invoke_function_t invoke, void *data, idle_function_t idle); - + /** * Kill the guest. * * @param idle idle function to call while waiting to termination */ void (*stop) (guest_t *this, idle_function_t idle); - + /** * Create a new interface in the current scenario. * @@ -118,21 +118,21 @@ struct guest_t { * @return created interface, or NULL if failed */ iface_t* (*create_iface)(guest_t *this, char *name); - + /** * Destroy an interface on guest. * * @param iface interface to destroy */ void (*destroy_iface)(guest_t *this, iface_t *iface); - + /** * Create an enumerator over all guest interfaces. * * @return enumerator over iface_t's */ enumerator_t* (*create_iface_enumerator)(guest_t *this); - + /** * Set the template COWFS overlay to use. * @@ -140,7 +140,7 @@ struct guest_t { * @return FALSE if failed */ bool (*load_template)(guest_t *this, char *parent); - + /** * Execute a command on the guests mconsole. * @@ -152,15 +152,15 @@ struct guest_t { */ int (*exec)(guest_t *this, void(*cb)(void*,char*,size_t), void *data, char *cmd, ...); - + /** * Execute a command on the guests mconsole, with output formatter. - * + * * If lines is TRUE, callback is invoked for each output line. Otherwise * the full result is returned in one callback invocation. - * + * * @note This function does not work with binary output. - * + * * @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 * @param data data to pass to callback @@ -170,15 +170,15 @@ struct guest_t { */ int (*exec_str)(guest_t *this, void(*cb)(void*,char*), bool lines, void *data, char *cmd, ...); - + /** * Called whenever a SIGCHILD for the guests PID is received. */ void (*sigchild)(guest_t *this); - + /** * Close and destroy a guest with all interfaces - */ + */ void (*destroy) (guest_t *this); }; diff --git a/src/dumm/iface.c b/src/dumm/iface.c index bf73c82a5..9910c392e 100644 --- a/src/dumm/iface.c +++ b/src/dumm/iface.c @@ -55,10 +55,10 @@ bool iface_control(char *name, bool up) int s; bool good = FALSE; struct ifreq ifr; - + memset(&ifr, 0, sizeof(struct ifreq)); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - + s = socket(AF_INET, SOCK_DGRAM, 0); if (!s) { @@ -104,7 +104,7 @@ static char* get_hostif(private_iface_t *this) */ static bool add_address(private_iface_t *this, host_t *addr) { - return (this->guest->exec(this->guest, NULL, NULL, + return (this->guest->exec(this->guest, NULL, NULL, "exec ip addr add %H dev %s", addr, this->guestif) == 0); } @@ -185,7 +185,7 @@ static guest_t* get_guest(private_iface_t *this) { return this->guest; } - + /** * destroy the tap device */ @@ -193,7 +193,7 @@ static bool destroy_tap(private_iface_t *this) { struct ifreq ifr; int tap; - + if (!iface_control(this->hostif, FALSE)) { DBG1("bringing iface down failed: %m"); @@ -201,7 +201,7 @@ static bool destroy_tap(private_iface_t *this) memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; strncpy(ifr.ifr_name, this->hostif, sizeof(ifr.ifr_name) - 1); - + tap = open(TAP_DEVICE, O_RDWR); if (tap < 0) { @@ -241,11 +241,11 @@ static char* create_tap(private_iface_t *this) if (ioctl(tap, TUNSETIFF, &ifr) < 0 || ioctl(tap, TUNSETPERSIST, 1) < 0 || ioctl(tap, TUNSETOWNER, 0)) - { + { DBG1("creating new tap device failed: %m"); close(tap); return NULL; - } + } close(tap); return strdup(ifr.ifr_name); } @@ -274,7 +274,7 @@ static void destroy(private_iface_t *this) iface_t *iface_create(char *name, guest_t *guest, mconsole_t *mconsole) { private_iface_t *this = malloc_thing(private_iface_t); - + this->public.get_hostif = (char*(*)(iface_t*))get_hostif; this->public.get_guestif = (char*(*)(iface_t*))get_guestif; this->public.add_address = (bool(*)(iface_t*, host_t *addr))add_address; diff --git a/src/dumm/iface.h b/src/dumm/iface.h index 7aef95c01..dabefaa17 100644 --- a/src/dumm/iface.h +++ b/src/dumm/iface.h @@ -32,21 +32,21 @@ typedef struct iface_t iface_t; * Interface in a guest, connected to a tap device on the host. */ struct iface_t { - + /** * Get the interface name in the guest (e.g. eth0). * * @return guest interface name */ char* (*get_guestif)(iface_t *this); - + /** * Get the interface name at the host (e.g. tap0). * * @return host interface (tap device) name */ char* (*get_hostif)(iface_t *this); - + /** * Add an address to the interface. * @@ -54,43 +54,43 @@ struct iface_t { * @return TRUE if address added */ bool (*add_address)(iface_t *this, host_t *addr); - + /** * Create an enumerator over all installed addresses. * * @return enumerator over host_t* */ enumerator_t* (*create_address_enumerator)(iface_t *this); - + /** * Remove an address from an interface. * * @param addr address to remove * @return TRUE if address removed */ - bool (*delete_address)(iface_t *this, host_t *addr); - + bool (*delete_address)(iface_t *this, host_t *addr); + /** * 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); - + /** * Get the bridge this iface is connected, or NULL. * * @return connected bridge, or NULL */ bridge_t* (*get_bridge)(iface_t *this); - + /** * Get the guest this iface belongs to. * * @return guest of this iface */ guest_t* (*get_guest)(iface_t *this); - + /** * Destroy an interface */ diff --git a/src/dumm/irdumm.c b/src/dumm/irdumm.c index bca8ce1db..7543e6bd6 100644 --- a/src/dumm/irdumm.c +++ b/src/dumm/irdumm.c @@ -17,6 +17,8 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #undef PACKAGE_STRING +#undef PACKAGE_BUGREPORT +#undef PACKAGE_URL #include <ruby.h> /** @@ -26,10 +28,10 @@ int main(int argc, char *argv[]) { int state, i; char buf[512]; - + ruby_init(); ruby_init_loadpath(); - + rb_eval_string_protect("require 'dumm' and include Dumm", &state); if (state) { @@ -53,7 +55,7 @@ int main(int argc, char *argv[]) { rb_p(ruby_errinfo); } - + ruby_finalize(); return 0; } diff --git a/src/dumm/main.c b/src/dumm/main.c index ba2801760..337a1a144 100644 --- a/src/dumm/main.c +++ b/src/dumm/main.c @@ -62,7 +62,7 @@ static void child_exited(VteReaper *vtereaper, gint pid, gint status) { enumerator_t *enumerator; page_t *page; - + enumerator = pages->create_enumerator(pages); while (enumerator->enumerate(enumerator, (void**)&page)) { @@ -81,7 +81,7 @@ static page_t* get_page(int num) { enumerator_t *enumerator; page_t *page, *found = NULL; - + enumerator = pages->create_enumerator(pages); while (enumerator->enumerate(enumerator, (void**)&page)) { @@ -114,7 +114,7 @@ void idle(void) static void start_guest() { page_t *page; - + page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); if (page && page->guest->get_state(page->guest) == GUEST_STOPPED) { @@ -128,7 +128,7 @@ static void start_all_guests() { enumerator_t *enumerator; page_t *page; - + enumerator = pages->create_enumerator(pages); while (enumerator->enumerate(enumerator, (void**)&page)) { @@ -146,7 +146,7 @@ static void start_all_guests() static void stop_guest() { page_t *page; - + page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); if (page && page->guest->get_state(page->guest) == GUEST_RUNNING) { @@ -163,17 +163,17 @@ static void quit() page_t *page; dumm->load_template(dumm, NULL); - + enumerator = pages->create_enumerator(pages); while (enumerator->enumerate(enumerator, &page)) { if (page->guest->get_state(page->guest) != GUEST_STOPPED) - { + { page->guest->stop(page->guest, idle); } } enumerator->destroy(enumerator); - gtk_main_quit(); + gtk_main_quit(); } static void error_dialog(char *msg) @@ -191,32 +191,32 @@ static void create_switch() { GtkWidget *dialog, *table, *label, *name; bridge_t *bridge; - + dialog = gtk_dialog_new_with_buttons("Create new switch", GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL); - + table = gtk_table_new(1, 2, TRUE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); - + label = gtk_label_new("Switch name"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0); gtk_widget_show(label); - + name = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(name); - + gtk_widget_show(table); - + while (TRUE) { switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_ACCEPT: - { + { if (streq(gtk_entry_get_text(GTK_ENTRY(name)), "")) { continue; @@ -250,34 +250,34 @@ static void connect_guest() bridge_t *bridge; iface_t *iface; enumerator_t *enumerator; - + page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); if (!page || page->guest->get_state(page->guest) != GUEST_RUNNING) { return; } - + dialog = gtk_dialog_new_with_buttons("Connect guest", GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL); - + table = gtk_table_new(2, 2, TRUE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); - + label = gtk_label_new("Interface name"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0); gtk_widget_show(label); - + name = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(name); - + label = gtk_label_new("Connected switch"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 0, 0); gtk_widget_show(label); - + box = gtk_combo_box_new_text(); gtk_table_attach(GTK_TABLE(table), box, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); @@ -288,20 +288,20 @@ static void connect_guest() } enumerator->destroy(enumerator); gtk_widget_show(box); - + gtk_widget_show(table); - + while (TRUE) { switch (gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_ACCEPT: - { + { if (streq(gtk_entry_get_text(GTK_ENTRY(name)), "")) { continue; } - + iface = page->guest->create_iface(page->guest, (char*)gtk_entry_get_text(GTK_ENTRY(name))); if (!iface) @@ -337,7 +337,7 @@ static void disconnect_guest() static void delete_guest() { page_t *page; - + page = get_page(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); if (page) { @@ -356,7 +356,7 @@ static page_t* create_page(guest_t *guest) { GtkWidget *label; page_t *page; - + page = g_new(page_t, 1); page->guest = guest; page->vte = vte_terminal_new(); @@ -375,55 +375,55 @@ static void create_guest() { guest_t *guest; GtkWidget *dialog, *table, *label, *name, *kernel, *master, *args; - + dialog = gtk_dialog_new_with_buttons("Create new guest", GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_NEW, GTK_RESPONSE_ACCEPT, NULL); - + table = gtk_table_new(4, 2, TRUE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); - + label = gtk_label_new("Guest name"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0); gtk_widget_show(label); - + label = gtk_label_new("UML kernel"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 0, 0); gtk_widget_show(label); - + label = gtk_label_new("Master filesystem"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, 0, 0, 0, 0); gtk_widget_show(label); - + label = gtk_label_new("Kernel arguments"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, 0, 0, 0, 0); gtk_widget_show(label); - + name = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), name, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(name); - + kernel = gtk_file_chooser_button_new("Select UML kernel image", GTK_FILE_CHOOSER_ACTION_OPEN); gtk_table_attach(GTK_TABLE(table), kernel, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(kernel); - + master = gtk_file_chooser_button_new("Select master filesystem", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_table_attach(GTK_TABLE(table), master, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(master); - + args = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), args, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0, 0); gtk_widget_show(args); - + gtk_widget_show(table); - + while (TRUE) { switch (gtk_dialog_run(GTK_DIALOG(dialog))) @@ -432,12 +432,12 @@ static void create_guest() { char *sname, *skernel, *smaster, *sargs; page_t *page; - + sname = (char*)gtk_entry_get_text(GTK_ENTRY(name)); skernel = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(kernel)); smaster = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(master)); sargs = (char*)gtk_entry_get_text(GTK_ENTRY(args)); - + if (!sname[0] || !skernel || !smaster) { continue; @@ -469,10 +469,10 @@ int main(int argc, char *argv[]) GtkWidget *dummMenu, *guestMenu, *switchMenu; enumerator_t *enumerator; guest_t *guest; - + library_init(NULL); gtk_init(&argc, &argv); - + pages = linked_list_create(); dumm = dumm_create(NULL); @@ -483,7 +483,7 @@ int main(int argc, char *argv[]) gtk_window_set_default_size(GTK_WINDOW (window), 1000, 500); g_signal_connect(G_OBJECT(vte_reaper_get()), "child-exited", G_CALLBACK(child_exited), NULL); - + /* add vbox with menubar, notebook */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); @@ -492,15 +492,15 @@ int main(int argc, char *argv[]) notebook = gtk_notebook_new(); g_object_set(G_OBJECT(notebook), "homogeneous", TRUE, NULL); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); - gtk_container_add(GTK_CONTAINER(vbox), notebook); + gtk_container_add(GTK_CONTAINER(vbox), notebook); /* Dumm menu */ menu = gtk_menu_new(); - dummMenu = gtk_menu_item_new_with_mnemonic("_Dumm"); + dummMenu = gtk_menu_item_new_with_mnemonic("_Dumm"); gtk_menu_bar_append(GTK_MENU_BAR(menubar), dummMenu); gtk_widget_show(dummMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(dummMenu), menu); - + /* Dumm -> exit */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", @@ -510,61 +510,61 @@ int main(int argc, char *argv[]) /* Guest menu */ menu = gtk_menu_new(); - guestMenu = gtk_menu_item_new_with_mnemonic("_Guest"); + guestMenu = gtk_menu_item_new_with_mnemonic("_Guest"); gtk_menu_bar_append(GTK_MENU_BAR(menubar), guestMenu); gtk_widget_show(guestMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(guestMenu), menu); - + /* Guest -> new */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(create_guest), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> delete */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(delete_guest), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + menuitem = gtk_separator_menu_item_new(); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> start */ menuitem = gtk_menu_item_new_with_mnemonic("_Start"); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(start_guest), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> startall */ menuitem = gtk_menu_item_new_with_mnemonic("Start _all"); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(start_all_guests), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> stop */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_STOP, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(stop_guest), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + menuitem = gtk_separator_menu_item_new(); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> connect */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_CONNECT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(connect_guest), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Guest -> disconnect */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DISCONNECT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", @@ -575,18 +575,18 @@ int main(int argc, char *argv[]) /* Switch menu */ menu = gtk_menu_new(); - switchMenu = gtk_menu_item_new_with_mnemonic("_Switch"); + switchMenu = gtk_menu_item_new_with_mnemonic("_Switch"); gtk_menu_bar_append(GTK_MENU_BAR(menubar), switchMenu); gtk_widget_show(switchMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(switchMenu), menu); - + /* Switch -> new */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(create_switch), NULL); gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_show(menuitem); - + /* Switch -> delete */ menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL); g_signal_connect(G_OBJECT(menuitem), "activate", @@ -594,13 +594,13 @@ int main(int argc, char *argv[]) gtk_menu_append(GTK_MENU(menu), menuitem); gtk_widget_set_sensitive(menuitem, FALSE); gtk_widget_show(menuitem); - - /* show widgets */ + + /* show widgets */ gtk_widget_show(menubar); gtk_widget_show(notebook); gtk_widget_show(vbox); gtk_widget_show(window); - + /* fill notebook with guests */ enumerator = dumm->create_guest_enumerator(dumm); while (enumerator->enumerate(enumerator, (void**)&guest)) @@ -608,12 +608,12 @@ int main(int argc, char *argv[]) create_page(guest); } enumerator->destroy(enumerator); - + gtk_main(); - + dumm->destroy(dumm); pages->destroy_function(pages, g_free); - + library_deinit(); return 0; } diff --git a/src/dumm/mconsole.c b/src/dumm/mconsole.c index 2ed96d562..35984bdd5 100644 --- a/src/dumm/mconsole.c +++ b/src/dumm/mconsole.c @@ -73,16 +73,16 @@ struct mconsole_reply { typedef struct mconsole_notify mconsole_notify; /** mconsole notify message */ struct mconsole_notify { - u_int32_t magic; - u_int32_t version; - enum { + u_int32_t magic; + u_int32_t version; + enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, MCONSOLE_USER_NOTIFY, - } type; - u_int32_t len; - char data[MCONSOLE_MAX_DATA]; + } type; + u_int32_t len; + char data[MCONSOLE_MAX_DATA]; }; /** @@ -95,14 +95,14 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t), mconsole_reply reply; int len, flags = 0; va_list args; - + memset(&request, 0, sizeof(request)); request.magic = MCONSOLE_MAGIC; request.version = MCONSOLE_VERSION; va_start(args, command); request.len = vsnprintf(request.data, sizeof(request.data), command, args); va_end(args); - + if (this->idle) { flags = MSG_DONTWAIT; @@ -117,13 +117,13 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t), (struct sockaddr*)&this->uml, sizeof(this->uml)); } while (len < 0 && (errno == EINTR || errno == EAGAIN)); - + if (len < 0) { DBG1("sending mconsole command to UML failed: %m"); return -1; } - do + do { len = recv(this->console, &reply, sizeof(reply), flags); if (len < 0 && (errno == EINTR || errno == EAGAIN)) @@ -157,7 +157,7 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t), } } while (reply.more); - + return reply.err; } @@ -174,7 +174,7 @@ static void ignore(void *data, char *buf, size_t len) static bool add_iface(private_mconsole_t *this, char *guest, char *host) { int tries = 0; - + while (tries++ < 5) { if (request(this, ignore, NULL, "config %s=tuntap,%s", guest, host) == 0) @@ -190,7 +190,7 @@ static bool add_iface(private_mconsole_t *this, char *guest, char *host) * Implementation of mconsole_t.del_iface. */ static bool del_iface(private_mconsole_t *this, char *guest) -{ +{ if (request(this, NULL, NULL, "remove %s", guest) != 0) { return FALSE; @@ -270,7 +270,7 @@ static bool wait_for_notify(private_mconsole_t *this, char *nsock) len = recvfrom(this->notify, ¬ify, sizeof(notify), flags, NULL, 0); } while (len < 0 && (errno == EINTR || errno == EAGAIN)); - + if (len < 0 || len >= sizeof(notify)) { DBG1("reading from mconsole notify socket failed: %m"); @@ -300,7 +300,7 @@ static bool wait_for_notify(private_mconsole_t *this, char *nsock) static bool setup_console(private_mconsole_t *this) { struct sockaddr_un addr; - + this->console = socket(AF_UNIX, SOCK_DGRAM, 0); if (this->console < 0) { @@ -326,20 +326,20 @@ static bool setup_console(private_mconsole_t *this) mconsole_t *mconsole_create(char *notify, void(*idle)(void)) { private_mconsole_t *this = malloc_thing(private_mconsole_t); - + this->public.add_iface = (bool(*)(mconsole_t*, char *guest, char *host))add_iface; this->public.del_iface = (bool(*)(mconsole_t*, char *guest))del_iface; this->public.exec = (int(*)(mconsole_t*, void(*cb)(void*,char*,size_t), void *data, char *cmd))exec; this->public.destroy = (void*)destroy; - + this->idle = idle; - + if (!wait_for_notify(this, notify)) { free(this); return NULL; } - + if (!setup_console(this)) { close(this->notify); @@ -348,9 +348,9 @@ mconsole_t *mconsole_create(char *notify, void(*idle)(void)) return NULL; } unlink(notify); - + wait_bootup(this); - + return &this->public; } diff --git a/src/dumm/mconsole.h b/src/dumm/mconsole.h index a4d93e48e..9fa2755ef 100644 --- a/src/dumm/mconsole.h +++ b/src/dumm/mconsole.h @@ -24,7 +24,7 @@ typedef struct mconsole_t mconsole_t; * UML mconsole, change running UML configuration using mconsole. */ struct mconsole_t { - + /** * Create a guest interface and connect it to tap host interface. * @@ -33,7 +33,7 @@ struct mconsole_t { * @return TRUE if interface created */ bool (*add_iface)(mconsole_t *this, char *guest, char *host); - + /** * Delete a guest interface. * @@ -41,7 +41,7 @@ struct mconsole_t { * @return TRUE if interface deleted */ bool (*del_iface)(mconsole_t *this, char *guest); - + /** * Execute a command on the mconsole. * @@ -52,7 +52,7 @@ struct mconsole_t { */ int (*exec)(mconsole_t *this, void(*cb)(void*,char*,size_t), void *data, char *cmd); - + /** * Destroy the mconsole instance */ |