summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky@linux.intel.com>2009-03-20 19:53:07 -0700
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2009-03-20 19:53:07 -0700
commit5d226de3eb549f6a2698f476ed13227694d3c977 (patch)
tree9a8dec53efd949c80f1a1f5af892e4ca4e118c39
parentd1d1fc136257768c632d7ba84f6f21c5bf1dc1b8 (diff)
wimaxll: add new dynamically expandable command line tool
This is basically a framework that permits easy expansion through plugins. Will replace all the wimaxll-* tools currently in place. Still not complete. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
-rw-r--r--Makefile.in2
-rw-r--r--bin/Makefile.am25
-rw-r--r--bin/Makefile.in130
-rw-r--r--bin/wimaxll-pl-reset.c96
-rw-r--r--bin/wimaxll-pl-rfkill.c165
-rw-r--r--bin/wimaxll.c455
-rwxr-xr-xconfigure206
-rw-r--r--configure.in8
-rw-r--r--doc/Makefile.in2
-rw-r--r--include/Makefile.in2
-rw-r--r--include/wimaxll/Makefile.in2
-rw-r--r--include/wimaxll/cmd.h105
-rw-r--r--lib/Makefile.in2
-rw-r--r--src/Makefile.in2
14 files changed, 1159 insertions, 43 deletions
diff --git a/Makefile.in b/Makefile.in
index dcb8e0a..bee48d1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -109,6 +109,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 469f0b9..c699ba7 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -10,7 +10,32 @@ LDADD = ../lib/libwimaxll.la $(LIBNL1_LIBS)
bin_SCRIPTS = wimax-tools-version
bin_PROGRAMS = \
+ wimaxll \
wimaxll-wait-for-state-change \
wimaxll-rfkill \
wimaxll-reset
+AM_CFLAGS = @GLIB_CFLAGS@ -DPLUGINDIR=\""$(plugindir)"\"
+AM_LDFLAGS = @GLIB_LIBS@ ../lib/libwimaxll.la $(LIBNL1_LIBS)
+
+wimaxll_LDFLAGS = $(AM_LDFLAGS) -ldl -Wl,--export-dynamic -Wl,--version-script=wimaxll.ver
+wimaxll_DEPENDENCIES = wimaxll.ver
+
+wimaxll.exp: $(wimaxll_OBJECTS)
+ nm -B *.o | awk '{ print $$3 }' | sort -u | grep -E -e '^w_' > $@
+
+wimaxll.ver: wimaxll.exp
+ echo "{ global:" > $@
+ cat $< | sed -e "s/\(.*\)/\1;/" >> $@
+ echo "local: *; };" >> $@
+
+plugindir = $(pkglibdir)/plugins
+plugin_LTLIBRARIES = \
+ wimaxll-pl-reset.la \
+ wimaxll-pl-rfkill.la
+
+plugin_LDFLAGS = -no-undefined -module -avoid-version \
+ -export-symbols-regex plugin
+
+wimaxll_pl_reset_la_LDFLAGS = $(plugin_LDFLAGS)
+wimaxll_pl_rfkill_la_LDFLAGS = $(plugin_LDFLAGS)
diff --git a/bin/Makefile.in b/bin/Makefile.in
index 46770b8..16b8030 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -15,6 +15,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -33,7 +34,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-bin_PROGRAMS = wimaxll-wait-for-state-change$(EXEEXT) \
+bin_PROGRAMS = wimaxll$(EXEEXT) wimaxll-wait-for-state-change$(EXEEXT) \
wimaxll-rfkill$(EXEEXT) wimaxll-reset$(EXEEXT)
subdir = bin
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
@@ -45,13 +46,40 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES = wimax-tools-version
-am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
+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__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(bindir)"
+pluginLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+wimaxll_pl_reset_la_LIBADD =
+wimaxll_pl_reset_la_SOURCES = wimaxll-pl-reset.c
+wimaxll_pl_reset_la_OBJECTS = wimaxll-pl-reset.lo
+wimaxll_pl_reset_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(wimaxll_pl_reset_la_LDFLAGS) $(LDFLAGS) -o $@
+wimaxll_pl_rfkill_la_LIBADD =
+wimaxll_pl_rfkill_la_SOURCES = wimaxll-pl-rfkill.c
+wimaxll_pl_rfkill_la_OBJECTS = wimaxll-pl-rfkill.lo
+wimaxll_pl_rfkill_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(wimaxll_pl_rfkill_la_LDFLAGS) $(LDFLAGS) -o $@
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
+wimaxll_SOURCES = wimaxll.c
+wimaxll_OBJECTS = wimaxll.$(OBJEXT)
+wimaxll_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+wimaxll_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(wimaxll_LDFLAGS) \
+ $(LDFLAGS) -o $@
wimaxll_reset_SOURCES = wimaxll-reset.c
wimaxll_reset_OBJECTS = wimaxll-reset.$(OBJEXT)
wimaxll_reset_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
wimaxll_reset_DEPENDENCIES = ../lib/libwimaxll.la \
$(am__DEPENDENCIES_1)
wimaxll_rfkill_SOURCES = wimaxll-rfkill.c
@@ -80,9 +108,11 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = wimaxll-reset.c wimaxll-rfkill.c \
+SOURCES = wimaxll-pl-reset.c wimaxll-pl-rfkill.c wimaxll.c \
+ wimaxll-reset.c wimaxll-rfkill.c \
wimaxll-wait-for-state-change.c
-DIST_SOURCES = wimaxll-reset.c wimaxll-rfkill.c \
+DIST_SOURCES = wimaxll-pl-reset.c wimaxll-pl-rfkill.c wimaxll.c \
+ wimaxll-reset.c wimaxll-rfkill.c \
wimaxll-wait-for-state-change.c
ETAGS = etags
CTAGS = ctags
@@ -116,6 +146,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
@@ -208,6 +240,20 @@ INCLUDES = \
LDADD = ../lib/libwimaxll.la $(LIBNL1_LIBS)
bin_SCRIPTS = wimax-tools-version
+AM_CFLAGS = @GLIB_CFLAGS@ -DPLUGINDIR=\""$(plugindir)"\"
+AM_LDFLAGS = @GLIB_LIBS@ ../lib/libwimaxll.la $(LIBNL1_LIBS)
+wimaxll_LDFLAGS = $(AM_LDFLAGS) -ldl -Wl,--export-dynamic -Wl,--version-script=wimaxll.ver
+wimaxll_DEPENDENCIES = wimaxll.ver
+plugindir = $(pkglibdir)/plugins
+plugin_LTLIBRARIES = \
+ wimaxll-pl-reset.la \
+ wimaxll-pl-rfkill.la
+
+plugin_LDFLAGS = -no-undefined -module -avoid-version \
+ -export-symbols-regex plugin
+
+wimaxll_pl_reset_la_LDFLAGS = $(plugin_LDFLAGS)
+wimaxll_pl_rfkill_la_LDFLAGS = $(plugin_LDFLAGS)
all: all-am
.SUFFIXES:
@@ -243,6 +289,37 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
wimax-tools-version: $(top_builddir)/config.status $(srcdir)/wimax-tools-version.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pluginLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(pluginLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(plugindir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$p'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$p"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+wimaxll-pl-reset.la: $(wimaxll_pl_reset_la_OBJECTS) $(wimaxll_pl_reset_la_DEPENDENCIES)
+ $(wimaxll_pl_reset_la_LINK) -rpath $(plugindir) $(wimaxll_pl_reset_la_OBJECTS) $(wimaxll_pl_reset_la_LIBADD) $(LIBS)
+wimaxll-pl-rfkill.la: $(wimaxll_pl_rfkill_la_OBJECTS) $(wimaxll_pl_rfkill_la_DEPENDENCIES)
+ $(wimaxll_pl_rfkill_la_LINK) -rpath $(plugindir) $(wimaxll_pl_rfkill_la_OBJECTS) $(wimaxll_pl_rfkill_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@@ -271,6 +348,9 @@ clean-binPROGRAMS:
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
+wimaxll$(EXEEXT): $(wimaxll_OBJECTS) $(wimaxll_DEPENDENCIES)
+ @rm -f wimaxll$(EXEEXT)
+ $(wimaxll_LINK) $(wimaxll_OBJECTS) $(wimaxll_LDADD) $(LIBS)
wimaxll-reset$(EXEEXT): $(wimaxll_reset_OBJECTS) $(wimaxll_reset_DEPENDENCIES)
@rm -f wimaxll-reset$(EXEEXT)
$(LINK) $(wimaxll_reset_OBJECTS) $(wimaxll_reset_LDADD) $(LIBS)
@@ -306,9 +386,12 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll-pl-reset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll-pl-rfkill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll-reset.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll-rfkill.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll-wait-for-state-change.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wimaxll.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -412,9 +495,9 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(PROGRAMS) $(SCRIPTS)
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS)
installdirs:
- for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
+ for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -443,7 +526,8 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-pluginLTLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
@@ -461,7 +545,7 @@ info: info-am
info-am:
-install-data-am:
+install-data-am: install-pluginLTLIBRARIES
install-dvi: install-dvi-am
@@ -497,25 +581,35 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-pluginLTLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
- clean-generic clean-libtool ctags distclean distclean-compile \
- distclean-generic distclean-libtool distclean-tags distdir dvi \
- dvi-am html html-am info info-am install install-am \
- install-binPROGRAMS install-binSCRIPTS install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
+ clean-generic clean-libtool clean-pluginLTLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-binSCRIPTS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pluginLTLIBRARIES \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-binPROGRAMS \
- uninstall-binSCRIPTS
+ uninstall-binSCRIPTS uninstall-pluginLTLIBRARIES
+
+
+wimaxll.exp: $(wimaxll_OBJECTS)
+ nm -B *.o | awk '{ print $$3 }' | sort -u | grep -E -e '^w_' > $@
+wimaxll.ver: wimaxll.exp
+ echo "{ global:" > $@
+ cat $< | sed -e "s/\(.*\)/\1;/" >> $@
+ echo "local: *; };" >> $@
# 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/bin/wimaxll-pl-reset.c b/bin/wimaxll-pl-reset.c
new file mode 100644
index 0000000..2f14a97
--- /dev/null
+++ b/bin/wimaxll-pl-reset.c
@@ -0,0 +1,96 @@
+/*
+ * Linux WiMax
+ * Swiss-army WiMAX knife
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define _GNU_SOURCE
+#include <argp.h>
+#include <error.h>
+#include <wimaxll.h>
+#include <wimaxll/version.h>
+#include <wimaxll/cmd.h>
+
+
+static
+struct argp_option reset_options[] = {
+ { 0 }
+};
+
+static
+int reset_parser(int key, char *arg, struct argp_state *state)
+{
+ return ARGP_ERR_UNKNOWN;
+}
+
+static
+int reset_fn(struct cmd *cmd, struct wimaxll_handle *wmx,
+ int argc, char **argv)
+{
+ int result;
+ result = argp_parse(&cmd->argp, argc, argv,
+ ARGP_IN_ORDER | ARGP_PARSE_ARGV0, 0, NULL);
+ if (result < 0)
+ goto error_argp_parse;
+ w_cmd_need_if(wmx);
+ result = wimaxll_reset(wmx);
+ if (result < 0)
+ w_error("reset failed: %d (%s)\n", result, strerror(-result));
+error_argp_parse:
+ return result;
+}
+
+static
+struct cmd reset_cmd = {
+ .name = "reset",
+ .argp = {
+ .options = reset_options,
+ .parser = reset_parser,
+ .args_doc = "",
+ .doc = "Resets a WiMAX device\n",
+ },
+ .fn = reset_fn,
+};
+
+static
+int reset_init(void)
+{
+ return w_cmd_register(&reset_cmd);
+}
+
+static
+void reset_exit(void)
+{
+ w_cmd_unregister(&reset_cmd);
+}
+
+
+PLUGIN("reset", WIMAXLL_VERSION, reset_init, reset_exit);
diff --git a/bin/wimaxll-pl-rfkill.c b/bin/wimaxll-pl-rfkill.c
new file mode 100644
index 0000000..cee3076
--- /dev/null
+++ b/bin/wimaxll-pl-rfkill.c
@@ -0,0 +1,165 @@
+/*
+ * Linux WiMax
+ * Swiss-army WiMAX knife
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define _GNU_SOURCE
+#include <argp.h>
+#include <wimaxll.h>
+#include <wimaxll/version.h>
+#include <wimaxll/cmd.h>
+
+
+struct rfkill_args
+{
+ struct cmd *cmd;
+ enum wimax_rf_state op;
+ char **argv;
+ size_t argc;
+};
+
+
+static
+struct argp_option rfkill_options[] = {
+ { 0 }
+};
+
+
+static
+int rfkill_parser(int key, char *arg, struct argp_state *state)
+{
+ int result = 0;
+ struct rfkill_args *args = state->input;
+
+ switch (key)
+ {
+ case ARGP_KEY_ARG:
+ if (!strcasecmp("on", arg))
+ args->op = WIMAX_RF_ON;
+ else if (!strcasecmp("off", arg))
+ args->op = WIMAX_RF_OFF;
+ else if (!strcasecmp("query", arg))
+ args->op = WIMAX_RF_QUERY;
+ else
+ argp_error(state, "E: unknown rfkill operation '%s'\n",
+ arg);
+ args->argv = &state->argv[state->next];
+ args->argc = state->argc - state->next;
+ /* Stop consuming args right here */
+ state->next = state->argc;
+ break;
+
+ default:
+ result = ARGP_ERR_UNKNOWN;
+ }
+ return result;
+}
+
+
+static
+char *rfkill_status_to_str(int status)
+{
+ int bytes = 0;
+ static char str[64];
+
+ if ((status & 0x1) == WIMAX_RF_OFF)
+ bytes += snprintf(str + bytes, sizeof(str),
+ "HW off");
+ else
+ bytes += snprintf(str + bytes, sizeof(str),
+ "HW on");
+ if ((status & 0x2) >> 1 == WIMAX_RF_OFF)
+ bytes += snprintf(str + bytes, sizeof(str),
+ " SW off");
+ else
+ bytes += snprintf(str + bytes, sizeof(str),
+ " SW on");
+ return str;
+}
+
+
+static
+int rfkill_fn(struct cmd *cmd, struct wimaxll_handle *wmx,
+ int argc, char **argv)
+{
+ int result;
+ struct rfkill_args args;
+
+ args.cmd = cmd;
+ args.op = WIMAX_RF_QUERY;
+ result = argp_parse(&cmd->argp, argc, argv,
+ 0, 0, &args);
+ if (result < 0)
+ goto error_argp_parse;
+ w_cmd_need_if(wmx);
+ result = wimaxll_rfkill(wmx, args.op);
+ if (result < 0) {
+ w_error("rfkill failed: %d (%s)\n", result, strerror(-result));
+ goto error_rfkill;
+ }
+ w_print("rfkill status is 0x%x (%s)\n", result,
+ rfkill_status_to_str(result));
+ if (args.op != WIMAX_RF_QUERY && (result & 0x2) >> 1 != args.op) {
+ w_error("rfkill failed to change device\n");
+ result = -EIO;
+ }
+error_rfkill:
+error_argp_parse:
+ return result;
+}
+
+static
+struct cmd rfkill_cmd = {
+ .name = "rfkill",
+ .argp = {
+ .options = rfkill_options,
+ .parser = rfkill_parser,
+ .args_doc = "[query]|on|off",
+ .doc = "Control the WiMAX radio state\n",
+ },
+ .fn = rfkill_fn,
+};
+
+
+static
+int rfkill_init(void)
+{
+ return w_cmd_register(&rfkill_cmd);
+}
+
+static
+void rfkill_exit(void)
+{
+ w_cmd_unregister(&rfkill_cmd);
+}
+
+PLUGIN("rfkill", WIMAXLL_VERSION, rfkill_init, rfkill_exit);
diff --git a/bin/wimaxll.c b/bin/wimaxll.c
new file mode 100644
index 0000000..e24ac1d
--- /dev/null
+++ b/bin/wimaxll.c
@@ -0,0 +1,455 @@
+/*
+ * Linux WiMax
+ * Swiss-army WiMAX knife
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Plugin based general tool -- it does the common infrastructure, but
+ * as of now, there is not much for it. Exported functions (to
+ * plugins) are wimaxll_*().
+ *
+ * A plugin must declare a non-static 'struct plugin plugin' data
+ * structure, with DECLARE_PLUGIN() [wimaxll-tool.h] in order to count.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <net/if.h>
+#include <errno.h>
+#include <argp.h>
+#include <dlfcn.h>
+#include <wimaxll.h>
+#include <wimaxll/version.h>
+#include "config.h"
+#include <wimaxll/cmd.h>
+#include <glib.h>
+#include <stdarg.h>
+
+
+/* Global state ... */
+
+struct main_args
+{
+ char ifname[IFNAMSIZ];
+ unsigned ifindex;
+ int verbosity;
+ char **cmd_argv;
+ size_t cmd_argc;
+} main_args;
+
+
+/*
+ * Messages
+ *
+ * If the log level is zero, we assume is a normal message that the
+ * user wants to see and send it to stdout. If it is negative, we
+ * consider it debugging info; if it is over zero, a warning/error
+ * message.
+ */
+void w_msg(unsigned level, const char *file, unsigned line,
+ const char *fmt, ...)
+{
+ FILE *f;
+ va_list vargs;
+ f = level != W_PRINT? stderr : stdout;
+ if (level <= main_args.verbosity || level == W_PRINT) {
+ va_start(vargs, fmt);
+ vfprintf(f, fmt, vargs);
+ va_end(vargs);
+ }
+}
+
+void w_vmsg(unsigned level, const char *file, unsigned line,
+ const char *fmt, va_list vargs)
+{
+ FILE *f;
+ f = level != W_PRINT? stderr : stdout;
+ if (level <= main_args.verbosity || level == W_PRINT)
+ vfprintf(f, fmt, vargs);
+}
+
+void w_abort(int result, const char *fmt, ...)
+{
+ va_list vargs;
+ va_start(vargs, fmt);
+ w_vmsg(W_ERROR, __FILE__, __LINE__, fmt, vargs);
+ va_end(vargs);
+ exit(result);
+}
+
+
+/* Command handling */
+
+static GList *__cmd_list = NULL;
+
+int w_cmd_register(struct cmd *cmd)
+{
+ __cmd_list = g_list_append(__cmd_list, cmd);
+ return 0;
+}
+
+void w_cmd_unregister(struct cmd *cmd)
+{
+ __cmd_list = g_list_remove(__cmd_list, cmd);
+}
+
+void w_cmd_need_if(struct wimaxll_handle *wmx)
+{
+ if (wmx == NULL)
+ w_abort(1, "E: no interface specified; use -i or environment "
+ "WIMAXLL_IF\n");
+}
+
+static
+void __cmd_list_itr(gpointer _cmd, gpointer _f)
+{
+ struct cmd *cmd = _cmd;
+
+ w_print("%s: ", cmd->name);
+ argp_help(&cmd->argp, stdout,
+ 0
+// | ARGP_HELP_SHORT_USAGE
+// | ARGP_HELP_SEE
+ | ARGP_HELP_LONG
+ | ARGP_HELP_PRE_DOC
+ | ARGP_HELP_POST_DOC
+ | ARGP_HELP_DOC
+// | ARGP_HELP_BUG_ADDR
+// | ARGP_HELP_LONG_ONLY
+ ,
+ cmd->name);
+}
+
+
+static
+void cmd_list(void)
+{
+ g_list_foreach(__cmd_list, __cmd_list_itr, NULL);
+ w_print("\nFor each command, --help is available\n");
+}
+
+
+static
+int __cmd_get_itr(gconstpointer _cmd, gconstpointer _name)
+{
+ const struct cmd *cmd = _cmd;
+ const char *name = _name;
+ return strcmp(name, cmd->name);
+}
+
+static
+struct cmd * cmd_get(const char *name)
+{
+ GList *l;
+ l = g_list_find_custom(__cmd_list, name, __cmd_get_itr);
+ return l == NULL? NULL : l->data;
+}
+
+
+/* Plugin handling */
+
+static GList *plugin_list = NULL;
+
+static
+int plugin_init(void)
+{
+ GList *itr;
+ GDir *dir;
+ const gchar *file;
+ gchar *filename;
+ GPatternSpec *pattern;
+
+ dir = g_dir_open(PLUGINDIR, 0, NULL);
+ if (dir == NULL)
+ goto error_no_plugindir;
+
+ pattern = g_pattern_spec_new("wimaxll-pl-*.so");
+ if (pattern == NULL)
+ goto error_pattern;
+
+ while ((file = g_dir_read_name(dir)) != NULL) {
+ void *handle;
+ struct plugin *plugin;
+
+ if (g_pattern_match(pattern, strlen(file), file, NULL) == FALSE) {
+ w_d2("skipping %s\n", file);
+ continue;
+ }
+ filename = g_build_filename(PLUGINDIR, file, NULL);
+
+ handle = dlopen(filename, RTLD_NOW);
+ if (handle == NULL) {
+ w_error("Can't load %s: %s\n", filename, dlerror());
+ goto error_pl_dlopen;
+ }
+
+ plugin = dlsym(handle, "plugin");
+ if (plugin == NULL) {
+ w_error("Can't load symbol 'plugin': %s\n", plugin->name);
+ goto error_pl_dlsym;
+ }
+ plugin->dl_handle = handle;
+ plugin->active = 0;
+
+ if (plugin->init == NULL) {
+ w_error("Plugin %s lacks init method\n", dlerror());
+ goto error_pl_noinit;
+ }
+
+ if (strcmp(plugin->version, WIMAXLL_VERSION)) {
+ w_error("Plugin '%s': version mismatch (%s vs %s needed)\n",
+ plugin->name, plugin->version, WIMAXLL_VERSION);
+ goto error_pl_version;
+ }
+
+ plugin_list = g_list_append(plugin_list, plugin);
+ g_free(filename);
+ continue;
+
+ error_pl_version:
+ error_pl_noinit:
+ error_pl_dlsym:
+ dlclose(handle);
+ error_pl_dlopen:
+ g_free(filename);
+ continue;
+ }
+
+ for (itr = plugin_list; itr; itr = itr->next) {
+ int result;
+ struct plugin *plugin = itr->data;
+
+ result = plugin->init();
+ if (result < 0) {
+ w_error("Plugin '%s' failed to initialize: %d\n",
+ plugin->name, result);
+ continue;
+ }
+ plugin->active = 1;
+ }
+
+ g_pattern_spec_free(pattern);
+error_pattern:
+ g_dir_close(dir);
+error_no_plugindir:
+ return 0;
+}
+
+static
+void plugin_exit(void)
+{
+ GList *itr;
+
+ for (itr = plugin_list; itr; itr = itr->next) {
+ struct plugin *plugin = itr->data;
+ if (plugin->active && plugin->exit)
+ plugin->exit();
+ dlclose(plugin->dl_handle);
+ }
+ g_list_free(plugin_list);
+}
+
+
+/* Main program & cmd line handling */
+
+const
+char *argp_program_version = "wimaxll v" VERSION;
+
+const
+char *argp_program_bug_address = PACKAGE_BUGREPORT;
+
+static
+struct argp_option main_options[] = {
+ { "verbose", 'v', 0, 0,
+ "Increase verbosity" },
+ { "quiet", 'q', 0, 0,
+ "Don't produce any output" },
+ { "silent", 's', 0, OPTION_ALIAS },
+
+ { 0, 0, 0, 0, " " },
+ { "interface",'i', "INTERFACE", 0,
+ "Network interface to work on (specify name or index); this value is "
+ "obtained by default from the environment variable WIMAXLL_IF." },
+
+ { 0, 0, 0, 0, " " },
+ { "commands", 'c', 0, 0,
+ "List available commands" },
+
+ { 0 }
+};
+
+
+#define __STRINGFY(a) #a
+#define STRINGFY(a) __STRINGFY(a)
+
+static
+int parse_if(struct main_args *args, const char *arg)
+{
+ if (arg == NULL) { /* to chain getenv */
+ args->ifindex = 0;
+ strcpy(args->ifname, "");
+ return 0;
+ }
+ if (sscanf(arg, "%u", &args->ifindex) == 1) {
+ if (if_indextoname(args->ifindex, args->ifname) == NULL) {
+ w_error("Cannot find interface index '%u'\n",
+ args->ifindex);
+ return -ENODEV;
+ }
+ }
+ else if (sscanf(arg, "%" STRINGFY(IFNAMSIZ) "s", args->ifname) == 1) {
+ args->ifindex = if_nametoindex(args->ifname);
+ if (args->ifindex == 0) {
+ w_error("Cannot find interface named '%s'\n",
+ args->ifname);
+ return -ENODEV;
+ }
+ }
+ else {
+ w_error("Cannot parse '%s' as network "
+ "interface name or index\n", arg);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static
+int main_parser(int key, char *arg, struct argp_state *state)
+{
+ int result = 0;
+ struct main_args *args = state->input;
+
+ w_d3("key %08x arg_num %d arg %s\n", key, state->arg_num, arg);
+ switch (key)
+ {
+ case 'q': case 's':
+ args->verbosity = 0;
+ break;
+ case 'v':
+ args->verbosity++;
+ break;
+ case 'i':
+ result = parse_if(args, arg);
+ break;
+ case 'c':
+ cmd_list();
+ exit(0);
+ break;
+
+ case ARGP_KEY_NO_ARGS:
+ argp_usage(state);
+
+ case ARGP_KEY_ARG:
+ w_d3("key arg, argc %d next %d\n", state->argc, state->next);
+ args->cmd_argv = &state->argv[state->next - 1];
+ args->cmd_argc = state->argc - (state->next - 1);
+ /* Stop consuming args right here */
+ state->next = state->argc;
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return result;
+}
+
+static
+struct argp main_argp = {
+ .options = main_options,
+ .parser = main_parser,
+ .args_doc = "COMMAND [COMMAND OPTIONS...]",
+ .doc =
+ "Control WiMAX devices at a very low level\n"
+ "\v"
+ "For a list of available commands, run with --commands"
+};
+
+int main(int argc, char **argv)
+{
+ int cnt;
+ int result;
+ struct cmd *cmd;
+ struct wimaxll_handle *wmx;
+ char *str;
+
+ str = getenv("WIMAXLL_VERBOSITY");
+ main_args.verbosity = str? atoi(str) : 0;
+ parse_if(&main_args, getenv("WIMAXLL_IF"));
+
+ plugin_init();
+
+ result = argp_parse(&main_argp, argc, argv, ARGP_IN_ORDER, 0, &main_args);
+ if (result < 0)
+ goto error_argp_parse;
+
+ w_d3("default args\n"
+ " ifname %s\n"
+ " ifindex %d\n"
+ " verbosity %d\n"
+ " command %s\n"
+ " cmd opts [%zu]:\n",
+ main_args.ifname, main_args.ifindex, main_args.verbosity,
+ main_args.cmd_argv[0], main_args.cmd_argc);
+ for(cnt = 0; cnt < main_args.cmd_argc; cnt++)
+ w_d3(" %s\n", main_args.cmd_argv[cnt]);
+
+ cmd = cmd_get(main_args.cmd_argv[0]);
+ if (cmd == NULL) {
+ w_error("command '%s' unrecognized; "
+ "check --commands\n", main_args.cmd_argv[0]);
+ result = -EINVAL;
+ goto error_cmd_get;
+ }
+
+ if (main_args.ifindex != 0) {
+ wmx = wimaxll_open(main_args.ifname);
+ if (wmx == NULL) {
+ w_error("%s: cannot open: %m\n", main_args.ifname);
+ result = -errno;
+ goto error_wimaxll_open;
+ }
+ }
+ else
+ wmx = NULL;
+ result = cmd->fn(cmd, wmx, main_args.cmd_argc, main_args.cmd_argv);
+ if (result < 0)
+ w_error("%s: failed: %s\n", cmd->name, strerror(-result));
+ wimaxll_close(wmx);
+ result = 0;
+error_wimaxll_open:
+error_cmd_get:
+error_argp_parse:
+ plugin_exit();
+ return result;
+}
+
diff --git a/configure b/configure
index 2d7ca65..bd8ec6f 100755
--- a/configure
+++ b/configure
@@ -884,6 +884,8 @@ PKG_CONFIG
LIBNL1_CFLAGS
LIBNL1_LIBS
I2400M_INCLUDES
+GLIB_CFLAGS
+GLIB_LIBS
LIBOBJS
LTLIBOBJS'
ac_subst_files=''
@@ -904,7 +906,9 @@ F77
FFLAGS
PKG_CONFIG
LIBNL1_CFLAGS
-LIBNL1_LIBS'
+LIBNL1_LIBS
+GLIB_CFLAGS
+GLIB_LIBS'
# Initialize some variables set by options.
@@ -1534,6 +1538,8 @@ Some influential environment variables:
LIBNL1_CFLAGS
C compiler flags for LIBNL1, overriding pkg-config
LIBNL1_LIBS linker flags for LIBNL1, overriding pkg-config
+ GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config
+ GLIB_LIBS linker flags for GLIB, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -4465,7 +4471,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4468 "configure"' > conftest.$ac_ext
+ echo '#line 4474 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -7522,11 +7528,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7525: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7531: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7529: \$? = $ac_status" >&5
+ echo "$as_me:7535: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7812,11 +7818,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7815: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7821: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7819: \$? = $ac_status" >&5
+ echo "$as_me:7825: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7916,11 +7922,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7919: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7925: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7923: \$? = $ac_status" >&5
+ echo "$as_me:7929: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -10293,7 +10299,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 10296 "configure"
+#line 10302 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10393,7 +10399,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 10396 "configure"
+#line 10402 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12794,11 +12800,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12797: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12803: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12801: \$? = $ac_status" >&5
+ echo "$as_me:12807: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -12898,11 +12904,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12901: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12907: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12905: \$? = $ac_status" >&5
+ echo "$as_me:12911: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14496,11 +14502,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14499: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14505: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14503: \$? = $ac_status" >&5
+ echo "$as_me:14509: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -14600,11 +14606,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14603: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14609: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14607: \$? = $ac_status" >&5
+ echo "$as_me:14613: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16820,11 +16826,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16823: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16829: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16827: \$? = $ac_status" >&5
+ echo "$as_me:16833: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -17110,11 +17116,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17113: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17119: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:17117: \$? = $ac_status" >&5
+ echo "$as_me:17123: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -17214,11 +17220,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:17217: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17223: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:17221: \$? = $ac_status" >&5
+ echo "$as_me:17227: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -20330,6 +20336,154 @@ fi
I2400M_INCLUDES="-I${LINUX_KERNEL}/include"
+{ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_dl_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+ dummy=yes
+else
+ { { echo "$as_me:$LINENO: error: dynamic linking loader is required" >&5
+echo "$as_me: error: dynamic linking loader is required" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+pkg_failed=no
+{ echo "$as_me:$LINENO: checking for GLIB" >&5
+echo $ECHO_N "checking for GLIB... $ECHO_C" >&6; }
+
+if test -n "$PKG_CONFIG"; then
+ if test -n "$GLIB_CFLAGS"; then
+ pkg_cv_GLIB_CFLAGS="$GLIB_CFLAGS"
+ else
+ if test -n "$PKG_CONFIG" && \
+ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.16\"") >&5
+ ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.16") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ pkg_cv_GLIB_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 >= 2.16" 2>/dev/null`
+else
+ pkg_failed=yes
+fi
+ fi
+else
+ pkg_failed=untried
+fi
+if test -n "$PKG_CONFIG"; then
+ if test -n "$GLIB_LIBS"; then
+ pkg_cv_GLIB_LIBS="$GLIB_LIBS"
+ else
+ if test -n "$PKG_CONFIG" && \
+ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.16\"") >&5
+ ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.16") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ pkg_cv_GLIB_LIBS=`$PKG_CONFIG --libs "glib-2.0 >= 2.16" 2>/dev/null`
+else
+ pkg_failed=yes
+fi
+ fi
+else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "glib-2.0 >= 2.16"`
+ else
+ GLIB_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "glib-2.0 >= 2.16"`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$GLIB_PKG_ERRORS" >&5
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ { { echo "$as_me:$LINENO: error: GLib >= 2.16 is required" >&5
+echo "$as_me: error: GLib >= 2.16 is required" >&2;}
+ { (exit 1); exit 1; }; }
+elif test $pkg_failed = untried; then
+ { { echo "$as_me:$LINENO: error: GLib >= 2.16 is required" >&5
+echo "$as_me: error: GLib >= 2.16 is required" >&2;}
+ { (exit 1); exit 1; }; }
+else
+ GLIB_CFLAGS=$pkg_cv_GLIB_CFLAGS
+ GLIB_LIBS=$pkg_cv_GLIB_LIBS
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ dummy=yes
+fi
+
+
+
ac_config_files="$ac_config_files Makefile doc/Makefile doc/doxygen.conf libwimaxll-0.pc libwimaxll-0-uninstalled.pc bin/Makefile bin/wimax-tools-version include/Makefile include/wimaxll-version.h include/wimaxll/Makefile include/wimaxll/version.h lib/Makefile src/Makefile"
@@ -21163,11 +21317,13 @@ PKG_CONFIG!$PKG_CONFIG$ac_delim
LIBNL1_CFLAGS!$LIBNL1_CFLAGS$ac_delim
LIBNL1_LIBS!$LIBNL1_LIBS$ac_delim
I2400M_INCLUDES!$I2400M_INCLUDES$ac_delim
+GLIB_CFLAGS!$GLIB_CFLAGS$ac_delim
+GLIB_LIBS!$GLIB_LIBS$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 19; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 21; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index a1a1f0f..15f7375 100644
--- a/configure.in
+++ b/configure.in
@@ -122,6 +122,14 @@ fi
AC_SUBST(I2400M_INCLUDES,"-I${LINUX_KERNEL}/include")
+AC_CHECK_LIB(dl, dlopen, dummy=yes,
+ AC_MSG_ERROR(dynamic linking loader is required))
+
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
+ AC_MSG_ERROR(GLib >= 2.16 is required))
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
AC_OUTPUT(Makefile
doc/Makefile
diff --git a/doc/Makefile.in b/doc/Makefile.in
index a324023..9eed296 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -75,6 +75,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
diff --git a/include/Makefile.in b/include/Makefile.in
index daeaada..977e04d 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -96,6 +96,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
diff --git a/include/wimaxll/Makefile.in b/include/wimaxll/Makefile.in
index 24a0453..6f546cf 100644
--- a/include/wimaxll/Makefile.in
+++ b/include/wimaxll/Makefile.in
@@ -85,6 +85,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
diff --git a/include/wimaxll/cmd.h b/include/wimaxll/cmd.h
new file mode 100644
index 0000000..c15fa1a
--- /dev/null
+++ b/include/wimaxll/cmd.h
@@ -0,0 +1,105 @@
+/*
+ * Linux WiMax
+ * Swiss-army WiMAX knife header file
+ *
+ *
+ * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This is the common interface for plugins to implement support for
+ * the 'wimaxll' command line tool.
+ */
+#ifndef __wimaxll__cmd_h__
+#define __wimaxll__cmd_h__
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <net/if.h>
+#include <errno.h>
+#include <argp.h>
+#include <wimaxll.h>
+
+struct wimax_handle;
+
+/* A plugin definition and declaration */
+struct plugin {
+ const char *name;
+ const char *version;
+ int (*init)(void);
+ void (*exit)(void);
+ void *dl_handle;
+ int active;
+};
+
+#define PLUGIN(_name, _version, _init, _exit) \
+struct plugin plugin = { \
+ .name = _name, \
+ .version = _version, \
+ .init = _init, \
+ .exit = _exit, \
+};
+
+/* Definining support for a command */
+struct cmd {
+ char *name;
+ struct argp argp;
+ int (*fn)(struct cmd *, struct wimaxll_handle *,
+ int argc, char **argv);
+};
+
+int w_cmd_register(struct cmd *);
+void w_cmd_unregister(struct cmd *);
+
+/* Misc utilities */
+void w_cmd_need_if(struct wimaxll_handle *);
+void w_abort(int result, const char *fmt, ...);
+void w_msg(unsigned, const char *, unsigned, const char *fmt, ...);
+
+/* Logging / printing */
+enum {
+ W_ERROR,
+ W_WARN,
+ W_INFO,
+ W_PRINT,
+ W_D1,
+ W_D2,
+ W_D3,
+};
+
+#define w_error(fmt...) w_msg(W_ERROR, __FILE__, __LINE__, "E: " fmt)
+#define w_warn(fmt...) w_msg(W_WARN, __FILE__, __LINE__, "W: " fmt)
+#define w_info(fmt...) w_msg(W_INFO, __FILE__, __LINE__, "I: " fmt)
+#define w_print(fmt...) w_msg(W_PRINT, __FILE__, __LINE__, fmt)
+#define w_d1(fmt...) w_msg(W_D1, __FILE__, __LINE__, "D1: " fmt)
+#define w_d2(fmt...) w_msg(W_D2, __FILE__, __LINE__, "D2: " fmt)
+#define w_d3(fmt...) w_msg(W_D3, __FILE__, __LINE__, "D3: " fmt)
+
+#endif /* #define __wimaxll__cmd_h__ */
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 1a37094..c9cee9d 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -120,6 +120,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@
diff --git a/src/Makefile.in b/src/Makefile.in
index d28fdb6..a5589c2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -99,6 +99,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
I2400M_INCLUDES = @I2400M_INCLUDES@
INSTALL = @INSTALL@