diff options
Diffstat (limited to 'src/stroke')
| -rw-r--r-- | src/stroke/Android.mk | 4 | ||||
| -rw-r--r-- | src/stroke/Makefile.am | 6 | ||||
| -rw-r--r-- | src/stroke/Makefile.in | 144 | ||||
| -rw-r--r-- | src/stroke/stroke.c | 64 | ||||
| -rw-r--r-- | src/stroke/stroke_keywords.c | 110 | ||||
| -rw-r--r-- | src/stroke/stroke_keywords.h | 7 | ||||
| -rw-r--r-- | src/stroke/stroke_keywords.txt | 7 | ||||
| -rw-r--r-- | src/stroke/stroke_msg.h | 31 |
8 files changed, 260 insertions, 113 deletions
diff --git a/src/stroke/Android.mk b/src/stroke/Android.mk index 69b3e54ca..320314c4d 100644 --- a/src/stroke/Android.mk +++ b/src/stroke/Android.mk @@ -2,9 +2,11 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # copy-n-paste from Makefile.am -LOCAL_SRC_FILES := \ +stroke_SOURCES := \ stroke.c stroke_msg.h stroke_keywords.c stroke_keywords.h +LOCAL_SRC_FILES := $(filter %.c,$(stroke_SOURCES)) + # build stroke ----------------------------------------------------------------- LOCAL_C_INCLUDES += \ diff --git a/src/stroke/Makefile.am b/src/stroke/Makefile.am index f93680b64..ed170bd08 100644 --- a/src/stroke/Makefile.am +++ b/src/stroke/Makefile.am @@ -4,11 +4,13 @@ stroke_SOURCES = \ stroke.c stroke_msg.h stroke_keywords.c stroke_keywords.h stroke_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(SOCKLIB) -INCLUDES = -I$(top_srcdir)/src/libstrongswan EXTRA_DIST = stroke_keywords.txt Android.mk BUILT_SOURCES = stroke_keywords.c MAINTAINERCLEANFILES = stroke_keywords.c -AM_CFLAGS = -DIPSEC_PIDDIR=\"${piddir}\" +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + -DIPSEC_PIDDIR=\"${piddir}\" stroke_keywords.c: $(srcdir)/stroke_keywords.txt $(srcdir)/stroke_keywords.h + $(AM_V_GEN) \ $(GPERF) -m 10 -D -C -G -t < $(srcdir)/stroke_keywords.txt > $@ diff --git a/src/stroke/Makefile.in b/src/stroke/Makefile.in index 946bacc20..21f9349cd 100644 --- a/src/stroke/Makefile.in +++ b/src/stroke/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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. @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -46,10 +63,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \ $(top_srcdir)/m4/macros/with.m4 \ $(top_srcdir)/m4/macros/enable-disable.m4 \ $(top_srcdir)/m4/macros/add-plugin.m4 \ - $(top_srcdir)/configure.in + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(ipsecdir)" @@ -60,42 +78,70 @@ am__DEPENDENCIES_1 = stroke_DEPENDENCIES = \ $(top_builddir)/src/libstrongswan/libstrongswan.la \ $(am__DEPENDENCIES_1) -DEFAULT_INCLUDES = -I.@am__isrc@ +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 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) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(stroke_SOURCES) DIST_SOURCES = $(stroke_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BFDLIB = @BFDLIB@ BTLIB = @BTLIB@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +COVERAGE_CFLAGS = @COVERAGE_CFLAGS@ +COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLIB = @DLLIB@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -104,13 +150,16 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GENHTML = @GENHTML@ GPERF = @GPERF@ +GPRBUILD = @GPRBUILD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ @@ -123,6 +172,7 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MYSQLCFLAG = @MYSQLCFLAG@ MYSQLCONFIG = @MYSQLCONFIG@ @@ -150,11 +200,13 @@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ RUBYINCLUDE = @RUBYINCLUDE@ +RUBYLIB = @RUBYLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCKLIB = @SOCKLIB@ STRIP = @STRIP@ +UNWINDLIB = @UNWINDLIB@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ @@ -162,6 +214,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -170,8 +223,6 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ attest_plugins = @attest_plugins@ -axis2c_CFLAGS = @axis2c_CFLAGS@ -axis2c_LIBS = @axis2c_LIBS@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -180,14 +231,19 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ c_plugins = @c_plugins@ +charon_natt_port = @charon_natt_port@ +charon_plugins = @charon_plugins@ +charon_udp_port = @charon_udp_port@ clearsilver_LIBS = @clearsilver_LIBS@ +cmd_plugins = @cmd_plugins@ datadir = @datadir@ datarootdir = @datarootdir@ dbusservicedir = @dbusservicedir@ -default_pkcs11 = @default_pkcs11@ +dev_headers = @dev_headers@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +fips_mode = @fips_mode@ gtk_CFLAGS = @gtk_CFLAGS@ gtk_LIBS = @gtk_LIBS@ h_plugins = @h_plugins@ @@ -201,17 +257,17 @@ imcvdir = @imcvdir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ +ipsec_script = @ipsec_script@ +ipsec_script_upper = @ipsec_script_upper@ ipsecdir = @ipsecdir@ ipsecgroup = @ipsecgroup@ ipseclibdir = @ipseclibdir@ ipsecuser = @ipsecuser@ -libcharon_plugins = @libcharon_plugins@ libdir = @libdir@ libexecdir = @libexecdir@ linux_headers = @linux_headers@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ maemo_CFLAGS = @maemo_CFLAGS@ maemo_LIBS = @maemo_LIBS@ manager_plugins = @manager_plugins@ @@ -221,16 +277,15 @@ mkdir_p = @mkdir_p@ nm_CFLAGS = @nm_CFLAGS@ nm_LIBS = @nm_LIBS@ nm_ca_dir = @nm_ca_dir@ +nm_plugins = @nm_plugins@ oldincludedir = @oldincludedir@ openac_plugins = @openac_plugins@ -p_plugins = @p_plugins@ pcsclite_CFLAGS = @pcsclite_CFLAGS@ pcsclite_LIBS = @pcsclite_LIBS@ pdfdir = @pdfdir@ piddir = @piddir@ pki_plugins = @pki_plugins@ plugindir = @plugindir@ -pluto_plugins = @pluto_plugins@ pool_plugins = @pool_plugins@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -262,11 +317,13 @@ stroke_SOURCES = \ stroke.c stroke_msg.h stroke_keywords.c stroke_keywords.h stroke_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la $(SOCKLIB) -INCLUDES = -I$(top_srcdir)/src/libstrongswan EXTRA_DIST = stroke_keywords.txt Android.mk BUILT_SOURCES = stroke_keywords.c MAINTAINERCLEANFILES = stroke_keywords.c -AM_CFLAGS = -DIPSEC_PIDDIR=\"${piddir}\" +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + -DIPSEC_PIDDIR=\"${piddir}\" + all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -304,8 +361,11 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-ipsecPROGRAMS: $(ipsec_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(ipsecdir)" || $(MKDIR_P) "$(DESTDIR)$(ipsecdir)" @list='$(ipsec_PROGRAMS)'; test -n "$(ipsecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(ipsecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(ipsecdir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ @@ -345,9 +405,9 @@ clean-ipsecPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -stroke$(EXEEXT): $(stroke_OBJECTS) $(stroke_DEPENDENCIES) +stroke$(EXEEXT): $(stroke_OBJECTS) $(stroke_DEPENDENCIES) $(EXTRA_stroke_DEPENDENCIES) @rm -f stroke$(EXEEXT) - $(LINK) $(stroke_OBJECTS) $(stroke_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(stroke_OBJECTS) $(stroke_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -359,25 +419,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stroke_keywords.Po@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -486,10 +546,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -592,6 +657,7 @@ uninstall-am: uninstall-ipsecPROGRAMS stroke_keywords.c: $(srcdir)/stroke_keywords.txt $(srcdir)/stroke_keywords.h + $(AM_V_GEN) \ $(GPERF) -m 10 -D -C -G -t < $(srcdir)/stroke_keywords.txt > $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/src/stroke/stroke.c b/src/stroke/stroke.c index bb299567b..75f014516 100644 --- a/src/stroke/stroke.c +++ b/src/stroke/stroke.c @@ -36,6 +36,8 @@ struct stroke_token { stroke_keyword_t kw; }; +static int output_verbosity = 1; /* CONTROL */ + static char* push_string(stroke_msg_t *msg, char *string) { unsigned long string_start = msg->length; @@ -61,7 +63,7 @@ static int send_stroke_msg (stroke_msg_t *msg) ctl_addr.sun_family = AF_UNIX; strcpy(ctl_addr.sun_path, STROKE_SOCKET); - msg->output_verbosity = 1; /* CONTROL */ + msg->output_verbosity = output_verbosity; sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) @@ -91,11 +93,11 @@ static int send_stroke_msg (stroke_msg_t *msg) /* we prompt if we receive a magic keyword */ if ((byte_count >= 12 && - strcmp(buffer + byte_count - 12, "Passphrase:\n") == 0) || + streq(buffer + byte_count - 12, "Passphrase:\n")) || (byte_count >= 10 && - strcmp(buffer + byte_count - 10, "Password:\n") == 0) || + streq(buffer + byte_count - 10, "Password:\n")) || (byte_count >= 5 && - strcmp(buffer + byte_count - 5, "PIN:\n") == 0)) + streq(buffer + byte_count - 5, "PIN:\n"))) { /* remove trailing newline */ pass = strrchr(buffer, '\n'); @@ -140,23 +142,25 @@ static int add_connection(char *name, msg.type = STR_ADD_CONN; msg.add_conn.name = push_string(&msg, name); - msg.add_conn.ikev2 = 1; - msg.add_conn.auth_method = 2; + msg.add_conn.version = 2; msg.add_conn.mode = 1; msg.add_conn.mobike = 1; msg.add_conn.dpd.action = 1; + msg.add_conn.install_policy = 1; msg.add_conn.me.id = push_string(&msg, my_id); msg.add_conn.me.address = push_string(&msg, my_addr); msg.add_conn.me.ikeport = 500; msg.add_conn.me.subnets = push_string(&msg, my_nets); msg.add_conn.me.sendcert = 1; + msg.add_conn.me.to_port = 65535; msg.add_conn.other.id = push_string(&msg, other_id); msg.add_conn.other.address = push_string(&msg, other_addr); msg.add_conn.other.ikeport = 500; msg.add_conn.other.subnets = push_string(&msg, other_nets); msg.add_conn.other.sendcert = 1; + msg.add_conn.other.to_port = 65535; return send_stroke_msg(&msg); } @@ -319,6 +323,8 @@ static int purge(stroke_keyword_t kw) static int export_flags[] = { EXPORT_X509, + EXPORT_CONN_CERT, + EXPORT_CONN_CHAIN, }; static int export(stroke_keyword_t kw, char *selector) @@ -364,6 +370,17 @@ static int user_credentials(char *name, char *user, char *pass) return send_stroke_msg(&msg); } +static int counters(int reset, char *name) +{ + stroke_msg_t msg; + + msg.type = STR_COUNTERS; + msg.length = offsetof(stroke_msg_t, buffer); + msg.counters.name = push_string(&msg, name); + msg.counters.reset = reset; + + return send_stroke_msg(&msg); +} static int set_loglevel(char *type, u_int level) { @@ -390,7 +407,7 @@ static void exit_usage(char *error) printf("Usage:\n"); printf(" Add a connection:\n"); printf(" stroke add NAME MY_ID OTHER_ID MY_ADDR OTHER_ADDR\\\n"); - printf(" MY_NET OTHER_NET MY_NETBITS OTHER_NETBITS\n"); + printf(" MY_NET OTHER_NET\n"); printf(" where: ID is any IKEv2 ID \n"); printf(" ADDR is a IPv4 address\n"); printf(" NET is a IPv4 subnet in CIDR notation\n"); @@ -400,22 +417,28 @@ static void exit_usage(char *error) printf(" Initiate a connection:\n"); printf(" stroke up NAME\n"); printf(" where: NAME is a connection name added with \"stroke add\"\n"); + printf(" Initiate a connection without blocking:\n"); + printf(" stroke up-nb NAME\n"); + printf(" where: NAME is a connection name added with \"stroke add\"\n"); printf(" Terminate a connection:\n"); printf(" stroke down NAME\n"); printf(" where: NAME is a connection name added with \"stroke add\"\n"); + printf(" Terminate a connection without blocking:\n"); + printf(" stroke down-nb NAME\n"); + printf(" where: NAME is a connection name added with \"stroke add\"\n"); printf(" Terminate a connection by remote srcip:\n"); printf(" stroke down-srcip START [END]\n"); printf(" where: START and optional END define the clients source IP\n"); printf(" Set loglevel for a logging type:\n"); printf(" stroke loglevel TYPE LEVEL\n"); - printf(" where: TYPE is any|dmn|mgr|ike|chd|job|cfg|knl|net|asn|enc|tnc|imc|imv|pts|tls|lib\n"); + printf(" where: TYPE is any|dmn|mgr|ike|chd|job|cfg|knl|net|asn|enc|tnc|imc|imv|pts|tls|esp|lib\n"); printf(" LEVEL is -1|0|1|2|3|4\n"); printf(" Show connection status:\n"); printf(" stroke status\n"); printf(" Show extended status information:\n"); printf(" stroke statusall\n"); printf(" Show extended status information without blocking:\n"); - printf(" stroke statusallnb\n"); + printf(" stroke statusall-nb\n"); printf(" Show list of authority and attribute certificates:\n"); printf(" stroke listcacerts|listocspcerts|listaacerts|listacerts\n"); printf(" Show list of end entity certificates, ca info records and crls:\n"); @@ -436,6 +459,8 @@ static void exit_usage(char *error) printf(" stroke purgeike\n"); printf(" Export credentials to the console:\n"); printf(" stroke exportx509 DN\n"); + printf(" stroke exportconncert connname\n"); + printf(" stroke exportconnchain connname\n"); printf(" Show current memory usage:\n"); printf(" stroke memusage\n"); printf(" Show leases of a pool:\n"); @@ -445,6 +470,8 @@ static void exit_usage(char *error) printf(" where: NAME is a connection name added with \"stroke add\"\n"); printf(" USERNAME is the username\n"); printf(" PASSWORD is the optional password, you'll be asked to enter it if not given\n"); + printf(" Show IKE counters:\n"); + printf(" stroke listcounters [connection-name]\n"); exit_error(error); } @@ -471,7 +498,7 @@ int main(int argc, char *argv[]) switch (token->kw) { case STROKE_ADD: - if (argc < 11) + if (argc < 9) { exit_usage("\"add\" needs more parameters..."); } @@ -488,6 +515,9 @@ int main(int argc, char *argv[]) } res = del_connection(argv[2]); break; + case STROKE_UP_NOBLK: + output_verbosity = -1; + /* fall-through */ case STROKE_UP: if (argc < 3) { @@ -495,6 +525,9 @@ int main(int argc, char *argv[]) } res = initiate_connection(argv[2]); break; + case STROKE_DOWN_NOBLK: + output_verbosity = -1; + /* fall-through */ case STROKE_DOWN: if (argc < 3) { @@ -554,7 +587,7 @@ int main(int argc, char *argv[]) case STROKE_LIST_ALGS: case STROKE_LIST_PLUGINS: case STROKE_LIST_ALL: - res = list(token->kw, argc > 2 && strcmp(argv[2], "--utc") == 0); + res = list(token->kw, argc > 2 && streq(argv[2], "--utc")); break; case STROKE_REREAD_SECRETS: case STROKE_REREAD_CACERTS: @@ -572,9 +605,11 @@ int main(int argc, char *argv[]) res = purge(token->kw); break; case STROKE_EXPORT_X509: + case STROKE_EXPORT_CONN_CERT: + case STROKE_EXPORT_CONN_CHAIN: if (argc != 3) { - exit_usage("\"exportx509\" needs a distinguished name"); + exit_usage("\"export\" needs a name"); } res = export(token->kw, argv[2]); break; @@ -593,6 +628,11 @@ int main(int argc, char *argv[]) } res = user_credentials(argv[2], argv[3], argc > 4 ? argv[4] : NULL); break; + case STROKE_COUNTERS: + case STROKE_COUNTERS_RESET: + res = counters(token->kw == STROKE_COUNTERS_RESET, + argc > 2 ? argv[2] : NULL); + break; default: exit_usage(NULL); } diff --git a/src/stroke/stroke_keywords.c b/src/stroke/stroke_keywords.c index b5ca2e143..ed0c4ceb4 100644 --- a/src/stroke/stroke_keywords.c +++ b/src/stroke/stroke_keywords.c @@ -54,12 +54,12 @@ struct stroke_token { stroke_keyword_t kw; }; -#define TOTAL_KEYWORDS 41 +#define TOTAL_KEYWORDS 48 #define MIN_WORD_LENGTH 2 #define MAX_WORD_LENGTH 15 -#define MIN_HASH_VALUE 2 -#define MAX_HASH_VALUE 44 -/* maximum key range = 43, duplicates = 0 */ +#define MIN_HASH_VALUE 3 +#define MAX_HASH_VALUE 59 +/* maximum key range = 57, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -75,32 +75,32 @@ hash (str, len) { static const unsigned char asso_values[] = { - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 15, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 0, 30, 1, - 1, 15, 45, 15, 45, 30, 45, 13, 0, 0, - 45, 9, 3, 45, 6, 18, 1, 0, 45, 45, - 5, 0, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45 + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 25, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 0, 18, 1, + 1, 15, 60, 23, 60, 23, 60, 11, 0, 7, + 60, 24, 14, 60, 6, 9, 16, 9, 60, 60, + 2, 3, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60 }; register int hval = len; @@ -125,17 +125,15 @@ hash (str, len) static const struct stroke_token wordlist[] = { - {"up", STROKE_UP}, {"add", STROKE_ADD}, {"del", STROKE_DEL}, {"down", STROKE_DOWN}, {"listall", STROKE_LIST_ALL}, - {"delete", STROKE_DELETE}, {"listcrls", STROKE_LIST_CRLS}, - {"rekey", STROKE_REKEY}, + {"up", STROKE_UP}, {"listaacerts", STROKE_LIST_AACERTS}, {"listcacerts", STROKE_LIST_CACERTS}, - {"listplugins", STROKE_LIST_PLUGINS}, + {"rekey", STROKE_REKEY}, {"rereadall", STROKE_REREAD_ALL}, {"listcerts", STROKE_LIST_CERTS}, {"rereadcrls", STROKE_REREAD_CRLS}, @@ -143,37 +141,47 @@ static const struct stroke_token wordlist[] = {"rereadaacerts", STROKE_REREAD_AACERTS}, {"rereadcacerts", STROKE_REREAD_CACERTS}, {"leases", STROKE_LEASES}, - {"unroute", STROKE_UNROUTE}, - {"listalgs", STROKE_LIST_ALGS}, + {"listcounters", STROKE_COUNTERS}, + {"delete", STROKE_DELETE}, {"status", STROKE_STATUS}, {"listacerts", STROKE_LIST_ACERTS}, {"route", STROKE_ROUTE}, {"statusall", STROKE_STATUSALL}, - {"purgeocsp", STROKE_PURGE_OCSP}, + {"rereadsecrets", STROKE_REREAD_SECRETS}, {"statusallnb", STROKE_STATUSALL_NOBLK}, - {"rereadocspcerts", STROKE_REREAD_OCSPCERTS}, - {"user-creds", STROKE_USER_CREDS}, - {"down-srcip", STROKE_DOWN_SRCIP}, - {"purgecrls", STROKE_PURGE_CRLS}, - {"listgroups", STROKE_LIST_GROUPS}, - {"listocsp", STROKE_LIST_OCSP}, + {"statusall-nb", STROKE_STATUSALL_NOBLK}, + {"listalgs", STROKE_LIST_ALGS}, + {"up-nb", STROKE_UP_NOBLK}, {"exportx509", STROKE_EXPORT_X509}, - {"rereadsecrets", STROKE_REREAD_SECRETS}, + {"listplugins", STROKE_LIST_PLUGINS}, + {"listcainfos", STROKE_LIST_CAINFOS}, + {"exportconncert", STROKE_EXPORT_CONN_CERT}, + {"exportconnchain", STROKE_EXPORT_CONN_CHAIN}, {"loglevel", STROKE_LOGLEVEL}, - {"purgeike", STROKE_PURGE_IKE}, + {"purgeocsp", STROKE_PURGE_OCSP}, + {"unroute", STROKE_UNROUTE}, + {"listocsp", STROKE_LIST_OCSP}, + {"down-srcip", STROKE_DOWN_SRCIP}, + {"listpubkeys", STROKE_LIST_PUBKEYS}, + {"purgecrls", STROKE_PURGE_CRLS}, + {"rereadocspcerts", STROKE_REREAD_OCSPCERTS}, {"listocspcerts", STROKE_LIST_OCSPCERTS}, {"memusage", STROKE_MEMUSAGE}, - {"listcainfos", STROKE_LIST_CAINFOS}, + {"purgeike", STROKE_PURGE_IKE}, + {"user-creds", STROKE_USER_CREDS}, + {"down-nb", STROKE_DOWN_NOBLK}, {"purgecerts", STROKE_PURGE_CERTS}, - {"listpubkeys", STROKE_LIST_PUBKEYS} + {"listgroups", STROKE_LIST_GROUPS}, + {"resetcounters", STROKE_COUNTERS_RESET} }; static const short lookup[] = { - -1, -1, 0, 1, 2, 3, -1, 4, 5, 6, -1, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40 + -1, -1, -1, 0, 1, 2, -1, 3, -1, 4, -1, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, -1, 43, 44, -1, -1, 45, -1, + -1, 46, -1, 47 }; #ifdef __GNUC__ diff --git a/src/stroke/stroke_keywords.h b/src/stroke/stroke_keywords.h index 554d071f3..4a1016277 100644 --- a/src/stroke/stroke_keywords.h +++ b/src/stroke/stroke_keywords.h @@ -23,7 +23,9 @@ typedef enum { STROKE_ROUTE, STROKE_UNROUTE, STROKE_UP, + STROKE_UP_NOBLK, STROKE_DOWN, + STROKE_DOWN_NOBLK, STROKE_DOWN_SRCIP, STROKE_REKEY, STROKE_LOGLEVEL, @@ -55,9 +57,13 @@ typedef enum { STROKE_PURGE_CERTS, STROKE_PURGE_IKE, STROKE_EXPORT_X509, + STROKE_EXPORT_CONN_CERT, + STROKE_EXPORT_CONN_CHAIN, STROKE_LEASES, STROKE_MEMUSAGE, STROKE_USER_CREDS, + STROKE_COUNTERS, + STROKE_COUNTERS_RESET, } stroke_keyword_t; #define STROKE_LIST_FIRST STROKE_LIST_PUBKEYS @@ -70,4 +76,3 @@ typedef struct stroke_token stroke_token_t; extern const stroke_token_t* in_word_set(register const char *str, register unsigned int len); #endif /* _STROKE_KEYWORDS_H_ */ - diff --git a/src/stroke/stroke_keywords.txt b/src/stroke/stroke_keywords.txt index 1d7ab8a45..ceb0dd253 100644 --- a/src/stroke/stroke_keywords.txt +++ b/src/stroke/stroke_keywords.txt @@ -30,13 +30,16 @@ delete, STROKE_DELETE route, STROKE_ROUTE unroute, STROKE_UNROUTE up, STROKE_UP +up-nb, STROKE_UP_NOBLK down, STROKE_DOWN +down-nb, STROKE_DOWN_NOBLK down-srcip, STROKE_DOWN_SRCIP rekey, STROKE_REKEY loglevel, STROKE_LOGLEVEL status, STROKE_STATUS statusall, STROKE_STATUSALL statusallnb, STROKE_STATUSALL_NOBLK +statusall-nb, STROKE_STATUSALL_NOBLK listpubkeys, STROKE_LIST_PUBKEYS listcerts, STROKE_LIST_CERTS listcacerts, STROKE_LIST_CACERTS @@ -62,6 +65,10 @@ purgecrls, STROKE_PURGE_CRLS purgecerts, STROKE_PURGE_CERTS purgeike, STROKE_PURGE_IKE exportx509, STROKE_EXPORT_X509 +exportconncert, STROKE_EXPORT_CONN_CERT +exportconnchain, STROKE_EXPORT_CONN_CHAIN leases, STROKE_LEASES memusage, STROKE_MEMUSAGE user-creds, STROKE_USER_CREDS +listcounters, STROKE_COUNTERS +resetcounters, STROKE_COUNTERS_RESET diff --git a/src/stroke/stroke_msg.h b/src/stroke/stroke_msg.h index 434122511..a4dfc5e7a 100644 --- a/src/stroke/stroke_msg.h +++ b/src/stroke/stroke_msg.h @@ -123,6 +123,10 @@ typedef enum export_flag_t export_flag_t; enum export_flag_t { /** export an X509 certificate */ EXPORT_X509 = 0x0001, + /** export an X509 end entity certificate for a connection */ + EXPORT_CONN_CERT = 0x0002, + /** export the complete trust chain of a connection */ + EXPORT_CONN_CHAIN = 0x0004, }; /** @@ -152,18 +156,21 @@ struct stroke_end_t { char *ca; char *ca2; char *groups; + char *groups2; char *cert_policy; char *updown; char *address; u_int16_t ikeport; char *sourceip; - int sourceip_mask; + char *dns; char *subnets; int sendcert; int hostaccess; int tohost; + int allow_any; u_int8_t protocol; - u_int16_t port; + u_int16_t from_port; + u_int16_t to_port; }; typedef struct stroke_msg_t stroke_msg_t; @@ -221,6 +228,8 @@ struct stroke_msg_t { STR_MEMUSAGE, /* set username and password for a connection */ STR_USER_CREDS, + /* print/reset counters */ + STR_COUNTERS, /* more to come */ } type; @@ -242,16 +251,15 @@ struct stroke_msg_t { /* data for STR_ADD_CONN */ struct { char *name; - int ikev2; - /* next three are deprecated, use stroke_end_t.auth instead */ - int auth_method; - u_int32_t eap_type; - u_int32_t eap_vendor; + int version; char *eap_identity; char *aaa_identity; + char *xauth_identity; int mode; int mobike; + int aggressive; int force_encap; + int fragmentation; int ipcomp; time_t inactivity; int proxy_mode; @@ -259,6 +267,7 @@ struct stroke_msg_t { int close_action; u_int32_t reqid; u_int32_t tfc; + u_int8_t ikedscp; crl_policy_t crl_policy; int unique; @@ -280,6 +289,7 @@ struct stroke_msg_t { } rekey; struct { time_t delay; + time_t timeout; int action; } dpd; struct { @@ -350,6 +360,13 @@ struct stroke_msg_t { char *username; char *password; } user_creds; + + /* data for STR_COUNTERS */ + struct { + /* reset or print counters? */ + int reset; + char *name; + } counters; }; char buffer[STROKE_BUF_LEN]; }; |
