[pisa-src] r1032 - in trunk: . pisabeacon

  • From: Tobias Heer <tobias.heer@xxxxxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 06 Oct 2009 21:18:20 +0200

Author: heer
Date: Tue Oct  6 21:18:19 2009
New Revision: 1032

Log:
Added a sender/receiver component for testing the beaconing functionality. 
Functionality and code maturity are far from perfect.

Added:
   trunk/pisabeacon/
   trunk/pisabeacon/Makefile
   trunk/pisabeacon/Makefile.am
   trunk/pisabeacon/beaconmain.c
Modified:
   trunk/Makefile.am
   trunk/configure.ac

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am   Tue Oct  6 20:31:25 2009        (r1031)
+++ trunk/Makefile.am   Tue Oct  6 21:18:19 2009        (r1032)
@@ -5,6 +5,8 @@
 ACLOCAL_AMFLAGS = -I m4
 EXTRA_DIST =
 
+PACKAGING_SCRIPT=test/packaging/create-package.sh
+
 # For "make dist"
 EXTRA_DIST += m4 docs/Doxyfile docs/INSTALL
 EXTRA_DIST += docs/architecture.txt docs/config.txt docs/packettype.txt
@@ -13,39 +15,11 @@
 EXTRA_DIST += tools/writeff.pl tools/tunnel/screamer.rb
 EXTRA_DIST += tools/tunnel/seteth1address
 
-SUBDIRS  = libpisa pairing performance pisacd pisand pisasd test
+SUBDIRS  = include libpisa performance pisacd pisand pairing pisasd test 
pisabeacon
 SUBDIRS += community-operator # has to be enabled for compilation on openwrt
 
-pisaincludedir=$(includedir)
-pisainclude_HEADERS= \
-       include/ac_config.h \
-       include/arp.h \
-       include/buffer.h \
-       include/checksum.h \
-       include/config.h \
-       include/conmgr.h \
-       include/crypto.h \
-       include/ctrlhandler.h \
-       include/debug.h \
-       include/dhcp.h \
-       include/global.h \
-       include/hitlist.h \
-       include/iwlib.h \
-       include/linkedlist.h \
-       include/log.h \
-       include/nat.h \
-       include/packet.h \
-       include/pisacd.h \
-       include/pisaconf.h \
-       include/pisand.h \
-       include/pisaperf.h \
-       include/pisasd.h \
-       include/socket.h \
-       include/token.h \
-       include/tunnel.h \
-       include/uthash.h \
-       include/util.h \
-       include/wireless.h
+rpm:
+       ${PACKAGING_SCRIPT} rpm
 
-deb rpm:
-       test/packaging/create-package.sh $@
+deb:
+       ${PACKAGING_SCRIPT} deb

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac  Tue Oct  6 20:31:25 2009        (r1031)
+++ trunk/configure.ac  Tue Oct  6 21:18:19 2009        (r1032)
@@ -182,6 +182,10 @@
 AC_SUBST(PISA_PISAND_INCLUDES, "$PISA_PISAND")
 AC_SUBST(PISA_PISASD, "$TOPSRC/pisasd")
 AC_SUBST(PISA_PISASD_INCLUDES, "$PISA_PISASD")
+AC_SUBST(PISA_PISABEACON, "$TOPSRC/pisabeacon")
+AC_SUBST(PISA_PISABEACON_INCLUDES, "$PISA_PISABEACON")
+
+
 
 AC_SUBST(PISA_PERFORMANCE, "$TOPSRC/performance")
 AC_SUBST(PISA_PERFORMANCE_INCLUDES, "$PISA_PERFORMANCE")
@@ -200,6 +204,7 @@
                 libpisa/Makefile
                 pisacd/Makefile
                 pisand/Makefile
+                pisabeacon/Makefile
                 pairing/Makefile
                 pisasd/Makefile
                 test/Makefile

Added: trunk/pisabeacon/Makefile
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/pisabeacon/Makefile   Tue Oct  6 21:18:19 2009        (r1032)
@@ -0,0 +1,510 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# pisabeacon/Makefile.  Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+# Copyright (c) 2008, Distributed Systems Group, RWTH Aachen
+# All rights reserved.
+#
+# Author: Tobias Heer <heer@xxxxxxxxxxxxxxxxx>
+
+
+pkgdatadir = $(datadir)/pisa
+pkglibdir = $(libdir)/pisa
+pkgincludedir = $(includedir)/pisa
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+sbin_PROGRAMS = pisabeacon$(EXEEXT)
+subdir = pisabeacon
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+       $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+       $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/ac_config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(sbindir)"
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(sbin_PROGRAMS)
+am_pisabeacon_OBJECTS = beaconmain.$(OBJEXT)
+pisabeacon_OBJECTS = $(am_pisabeacon_OBJECTS)
+pisabeacon_LDADD = $(LDADD)
+pisabeacon_DEPENDENCIES =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(pisabeacon_SOURCES)
+DIST_SOURCES = $(pisabeacon_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/heer/pisa/trunk/config/missing --run aclocal-1.10
+AMTAR = ${SHELL} /home/heer/pisa/trunk/config/missing --run tar
+AR = ar
+AUTOCONF = ${SHELL} /home/heer/pisa/trunk/config/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/heer/pisa/trunk/config/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/heer/pisa/trunk/config/missing --run automake-1.10
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -Wall -g
+CPP = gcc -E
+CPPFLAGS = 
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DSYMUTIL = 
+DUMPBIN = 
+ECHO_C = 
+ECHO_N = -n
+ECHO_T = 
+EGREP = /bin/grep -E
+EXEEXT = 
+FGREP = /bin/grep -F
+GDB_CFLAGS = -g
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+LD = /usr/bin/ld -m elf_i386
+LDFLAGS = 
+LEX = flex
+LEXLIB = -lfl
+LEX_OUTPUT_ROOT = lex.yy
+LIBOBJS = 
+LIBS = -lconfig -lcrypto 
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO = 
+LN_S = ln -s
+LTLIBOBJS = 
+MAKEINFO = ${SHELL} /home/heer/pisa/trunk/config/missing --run makeinfo
+MKDIR_P = /bin/mkdir -p
+NM = /usr/bin/nm -B
+NMEDIT = 
+OBJDUMP = objdump
+OBJEXT = o
+OPENWRT_CFLAGS = 
+OTOOL = 
+OTOOL64 = 
+PACKAGE = pisa
+PACKAGE_BUGREPORT = pisa@xxxxxxxxxxxxx
+PACKAGE_NAME = pisa
+PACKAGE_STRING = pisa 0.0.1031
+PACKAGE_TARNAME = pisa
+PACKAGE_VERSION = 0.0.1031
+PATH_SEPARATOR = :
+PISA_COMMON_INCLUDES = /home/heer/pisa/trunk/include
+PISA_HIPL_SRCDIR = /home/heer/pisa/trunk/../../hipl--midauth--2.6
+PISA_LIBCONFIG = /usr/lib
+PISA_LIBCONFIG_LIB = /usr/lib
+PISA_LIBCONFIG_LIB_DYNAMIC = /usr/lib/libconfig.so
+PISA_LIBCONFIG_LIB_STATIC = /usr/lib/libconfig.a
+PISA_LIBPISA = /home/heer/pisa/trunk/libpisa
+PISA_LIBPISA_INCLUDES = /home/heer/pisa/trunk/libpisa
+PISA_LIBPISA_LIB = /home/heer/pisa/trunk/libpisa/.libs
+PISA_LIBPISA_LIB_DYNAMIC = /home/heer/pisa/trunk/libpisa/.libs/libpisa.so
+PISA_LIBPISA_LIB_STATIC = /home/heer/pisa/trunk/libpisa/.libs/libpisa.a
+PISA_PERFORMANCE = /home/heer/pisa/trunk/performance
+PISA_PERFORMANCE_INCLUDES = /home/heer/pisa/trunk/performance
+PISA_PERFORMANCE_LIB = /home/heer/pisa/trunk/performance/.libs
+PISA_PERFORMANCE_LIB_DYNAMIC = 
/home/heer/pisa/trunk/performance/.libs/libperformance.so
+PISA_PERFORMANCE_LIB_STATIC = 
/home/heer/pisa/trunk/performance/.libs/libperformance.a
+PISA_PISABEACON = /home/heer/pisa/trunk/pisabeacon
+PISA_PISABEACON_INCLUDES = /home/heer/pisa/trunk/pisabeacon
+PISA_PISACD = /home/heer/pisa/trunk/pisacd
+PISA_PISACD_INCLUDES = /home/heer/pisa/trunk/pisacd
+PISA_PISAND = /home/heer/pisa/trunk/pisand
+PISA_PISAND_INCLUDES = /home/heer/pisa/trunk/pisand
+PISA_PISASD = /home/heer/pisa/trunk/pisasd
+PISA_PISASD_INCLUDES = /home/heer/pisa/trunk/pisasd
+RANLIB = ranlib
+SED = /bin/sed
+SET_MAKE = 
+SHELL = /bin/bash
+STRIP = strip
+TOPSRC = /home/heer/pisa/trunk
+VERSION = 0.0.1031
+YACC = bison -y
+YFLAGS = 
+abs_builddir = /home/heer/pisa/trunk/pisabeacon
+abs_srcdir = /home/heer/pisa/trunk/pisabeacon
+abs_top_builddir = /home/heer/pisa/trunk
+abs_top_srcdir = /home/heer/pisa/trunk
+ac_ct_CC = gcc
+ac_ct_DUMPBIN = 
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias = 
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = $(SHELL) /home/heer/pisa/trunk/config/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+lt_ECHO = echo
+mandir = ${datarootdir}/man
+mkdir_p = /bin/mkdir -p
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias = 
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+AUTOMAKE_OPTIONS = foreign
+INCLUDES = -I$(top_srcdir)/include
+
+#EXTRA_DIST = pisacd.conf
+#sysconf_DATA = pisacd.conf
+#sysconfdir = /etc/pisa
+pisalsddir = .
+LDADD = -lm
+pisabeacon_SOURCES = beaconmain.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  pisabeacon/Makefile'; 
\
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --foreign  pisabeacon/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 
$(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 
$(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure 
$(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(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
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
+       @list='$(sbin_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 $(sbinPROGRAMS_INSTALL) '$$p' 
'$(DESTDIR)$(sbindir)/$$f'"; \
+          $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) 
--mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 
1; \
+         else :; fi; \
+       done
+
+uninstall-sbinPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(sbin_PROGRAMS)'; for p in $$list; do \
+         f=`echo "$$p" | sed 
's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+         echo " rm -f '$(DESTDIR)$(sbindir)/$$f'"; \
+         rm -f "$(DESTDIR)$(sbindir)/$$f"; \
+       done
+
+clean-sbinPROGRAMS:
+       @list='$(sbin_PROGRAMS)'; for p in $$list; do \
+         f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+         echo " rm -f $$p $$f"; \
+         rm -f $$p $$f ; \
+       done
+pisabeacon$(EXEEXT): $(pisabeacon_OBJECTS) $(pisabeacon_DEPENDENCIES) 
+       @rm -f pisabeacon$(EXEEXT)
+       $(LINK) $(pisabeacon_OBJECTS) $(pisabeacon_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+include ./$(DEPDIR)/beaconmain.Po
+
+.c.o:
+       $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#      source='$<' object='$@' libtool=no \
+#      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#      $(COMPILE) -c $<
+
+.c.obj:
+       $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) 
'$<'`
+       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#      source='$<' object='$@' libtool=no \
+#      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#      $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+       $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+#      source='$<' object='$@' libtool=yes \
+#      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#      $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       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; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       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; }; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       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" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         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 $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+       for dir in "$(DESTDIR)$(sbindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-sbinPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-sbinPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-sbinPROGRAMS ctags distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-sbinPROGRAMS 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-sbinPROGRAMS
+
+#include_HEADERS = 
+# 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:

Added: trunk/pisabeacon/Makefile.am
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/pisabeacon/Makefile.am        Tue Oct  6 21:18:19 2009        (r1032)
@@ -0,0 +1,25 @@
+# Copyright (c) 2008, Distributed Systems Group, RWTH Aachen
+# All rights reserved.
+#
+# Author: Tobias Heer <heer@xxxxxxxxxxxxxxxxx>
+
+AUTOMAKE_OPTIONS = foreign
+
+CFLAGS = -Wall -g
+INCLUDES = -I$(top_srcdir)/include
+
+#bin_PROGRAMS = 
+sbin_PROGRAMS = pisabeacon
+
+#EXTRA_DIST = pisacd.conf
+#sysconf_DATA = pisacd.conf
+#sysconfdir = /etc/pisa
+
+pisalsddir = .
+
+LDADD =
+LDFLAGS = @LDFLAGS@
+
+LDADD += -lm
+pisabeacon_SOURCES = beaconmain.c
+#include_HEADERS = 

Added: trunk/pisabeacon/beaconmain.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/pisabeacon/beaconmain.c       Tue Oct  6 21:18:19 2009        (r1032)
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2009, Distributed Systems Group, RWTH Aachen
+ * All rights reserved.
+ */
+
+/**
+ * @file beaconmain.c
+ * @brief Implementation of the PISA location beacon.
+ * @author Tobias Heer <heer@xxxxxxxxxxxxxxxxx>
+ * @date Oct. 2009
+ */
+
+#include <signal.h>            /* signals (who'd guess) */
+#include <getopt.h>            /* command line parsing */
+#include <string.h>            /* strncopy */
+#include <arpa/inet.h> /* inet_aton(...) */
+#include <time.h>              /* time(...) */
+#include <errno.h>             /* error numbers */
+#include <stdio.h>             /* printf(...) */
+#include <stdlib.h>            /* malloc(...) */
+#include <unistd.h>            /* usleep(...) */
+/**
+ * A set of options, including each long option and single-letter option
+ */
+static const struct option plb_longopts[] = { { "geo_id", required_argument,
+               NULL, 'i' }, { "bc_interval", required_argument, NULL, 't' }, {
+               "bc_addr", required_argument, NULL, 'd' }, { "bc_port",
+               required_argument, NULL, 'p' },
+               { "background", no_argument, NULL, 'b' }, { "listen", 
no_argument,
+                               NULL, 'l' }, { "debug", no_argument, NULL, 'd' 
}, { "version",
+                               no_argument, NULL, 'v' }, { "help", 
no_argument, NULL, 'h' }, {
+                               NULL, 0, NULL, '\0' } };
+
+typedef enum {
+       PLB_SENDER = 0, /* sender mode: broadcast packets */
+       PLB_LISTENER = 1
+/* listener mode: listen for location packets */
+} plb_mode;
+
+/** default values */
+#define PLB_DEFAULT_PORT 2634
+#define PLB_DEFAULT_ADDR "192.168.7.255"
+#define PLB_DEFAULT_INTERVAL 100 /*ms*/
+
+/** size of the buffer for the custom script */
+#define LEN_SCRIPT_NAME 128
+
+typedef struct {
+
+       /** Run in daemon mode */
+       int is_daemon;
+
+       /** Sender: Broadcast interval */
+       int bc_interval;
+
+       /** Socket for broadcast */
+       int bc_fd;
+
+       /** Run in listener or server mode */
+       plb_mode mode;
+
+       /**Sender: Geo ID of the AP*/
+       uint16_t geo_id;
+
+       /** Sender: Destination address */
+       struct sockaddr_in bc_addr;
+
+       /** Listener Script that is called when geo id changes */
+       char run_script[LEN_SCRIPT_NAME];
+
+} plb_ctx;
+
+/** packet contents for geo information - very simplistic so far */
+typedef struct {
+       uint16_t geo_id;
+}__attribute__((__packed__)) geo_packet;
+
+/**
+ * Prototype declarations of functions.
+ */
+static void plb_init(plb_ctx* ctx, const int argc, char *argv[]);
+static void plb_get_cmdargs(plb_ctx* ctx, const int argc, char **argv);
+static void plb_quit(int quitcode);
+static void plb_print_version(void);
+static void plb_print_usage(char **argv);
+
+/**
+ * The main function of this location server daemon.
+ *
+ * @param argc   number of command arguments
+ * @param argv   pointer to the array of command arguments
+ */
+int main(int argc, char *argv[]) {
+       /* main context variable*/
+       plb_ctx ctx;
+
+       /* buffer for sending and receiving packets */
+       geo_packet packet;
+
+       /* Initialize basic settings */
+       plb_init(&ctx, argc, argv);
+
+       /* prepare socket */
+       if ((ctx.bc_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
+               perror("Err: couldn't create socket");
+               exit(EXIT_FAILURE);
+       }
+
+       /* addr and port are already set by init */
+       ctx.bc_addr.sin_family = AF_INET;
+
+
+       if (ctx.mode == PLB_SENDER) {
+               /* Sender mode: send broadcasts */
+
+               /* Set socket option to allow broadcasts */
+               int option = 1;
+               if (setsockopt(ctx.bc_fd, SOL_SOCKET, SO_BROADCAST, &option,
+                               sizeof(option))) {
+                       perror("Err: Cannot set socket to broadcast");
+                       exit(EXIT_FAILURE);
+               }
+
+               printf("Sending geo location id (%d) to:%s, %d with interval 
%d\n",
+                               ctx.geo_id, inet_ntoa(ctx.bc_addr.sin_addr),
+                               ntohs(ctx.bc_addr.sin_port), ctx.bc_interval);
+
+               /* set packet contents */
+               packet.geo_id = htons(ctx.geo_id);
+
+               /* loop infinitely (or until signal arrives) */
+               while (1) {
+                       if (sendto(ctx.bc_fd, &packet, sizeof(packet), 0,
+                                       (struct sockaddr*) &ctx.bc_addr, 
sizeof(ctx.bc_addr)) < 0) {
+                               perror("Send failed:");
+                               exit(EXIT_FAILURE);
+                       }
+                       /*wait before sending next packet */
+                       usleep(ctx.bc_interval * 1000);
+               }
+       } else {
+               /* Listener mode: wait for incoming packets */
+               socklen_t len;  
+               uint16_t last_geo_id;
+
+               /* buffer for creating script call*/
+               char script_buffer[LEN_SCRIPT_NAME + 128]; /* 128 is for the 
length of the script arguments */
+               
+               len = sizeof(ctx.bc_addr);
+               last_geo_id = 0;
+
+               ctx.bc_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+               bind(ctx.bc_fd, (struct sockaddr *) &ctx.bc_addr, 
sizeof(ctx.bc_addr));
+
+               printf("Waiting for geo location id on port %d\n",
+                               ntohs(ctx.bc_addr.sin_port));
+
+
+               /* keep receiving until signal arrives */
+               while (1) {
+                       if (recvfrom(ctx.bc_fd, &packet, sizeof(packet), 0,
+                                       (struct sockaddr *) &ctx.bc_addr, &len) 
!= sizeof(packet)) {
+                               perror("Receive failed:");
+                       } else {
+                               if (htons(packet.geo_id) != last_geo_id) {
+                                       /* BEWARE: if geo id ever becomes a 
string, this might be a window for an injection attack */
+                                       last_geo_id = htons(packet.geo_id);
+                                       /* run the specified script */
+                                       if (ctx.run_script[0] != 0) {
+                                               sprintf(script_buffer, "%s %d", 
ctx.run_script, last_geo_id);
+                                               system(script_buffer);
+                                       } else {
+                                               printf("New geo ID: %d\n", 
last_geo_id);
+                                       }
+                               }
+                       }
+
+               }
+
+       }
+}
+
+/**
+ * Initialize the basic settings before starting the main loop.
+ */
+static void plb_init(plb_ctx* ctx, const int argc, char *argv[]) {
+       /* Set signal handler for each signal */
+
+       signal(SIGTERM, plb_quit);
+       signal(SIGINT, plb_quit);
+       signal(SIGQUIT, plb_quit);
+       signal(SIGILL, plb_quit);
+       signal(SIGPIPE, SIG_IGN);
+       signal(SIGBUS, plb_quit);
+
+       ctx->mode = PLB_SENDER; /*default s sender mode */
+       ctx->is_daemon = 0; /*we're not in daemon mode */
+       ctx->bc_addr.sin_port = htons(PLB_DEFAULT_PORT);
+       ctx->bc_interval = PLB_DEFAULT_INTERVAL;
+       ctx->geo_id = htons(0);
+       ctx->run_script[0] = 0;
+       inet_aton(PLB_DEFAULT_ADDR,
+                       (struct in_addr*) &(ctx->bc_addr.sin_addr.s_addr));
+
+       /* Receive and parse command line arguments. */
+       plb_get_cmdargs(ctx, argc, argv);
+
+       /* fork in case of background running mode */
+       if (ctx->is_daemon) {
+               if (fork() > 0)
+                       exit(EXIT_SUCCESS);
+       } else {
+               printf("Not running in background\n");
+       }
+
+}
+/**
+ * Get command line arguments and parse them.
+ *
+ * @param argc        number of command arguments
+ * @param argv        pointer to the array of command arguments
+ */
+static void plb_get_cmdargs(plb_ctx* ctx, const int argc, char **argv) {
+       int c = 0;
+       int option_index = 0;
+
+       while ((c = getopt_long(argc, argv, "d:bli:g:p:s:vh", plb_longopts,
+                       &option_index)) != -1) {
+               switch (c) {
+
+               /* Sender options */
+               case 'd':
+                       if (inet_pton(AF_INET, optarg, &ctx->bc_addr.sin_addr) 
!= 1) {
+                               printf("\nWrong address for option d 
(broadcast_address)\n");
+                               exit(1);
+                       }
+                       break;
+               case 'i':
+                       ctx->bc_interval = atoi(optarg);
+                       if (!ctx->bc_interval || errno != 0) {
+                               printf("Interval %s is invalid (errno: %d, 
buffer size: %d)\n",
+                                               optarg, errno, 
ctx->bc_interval);
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+               case 'g':
+                       ctx->geo_id = atoi(optarg);
+                       if (!ctx->geo_id || errno != 0) {
+                               printf("Interval %s is invalid (errno: %d, 
buffer size: %d)\n",
+                                               optarg, errno, 
ctx->bc_interval);
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+
+                       /* Listener options */
+               case 's':
+                       strncpy(ctx->run_script, optarg, LEN_SCRIPT_NAME);
+                       break;
+
+                       /* General options */
+               case 'b':
+                       ctx->is_daemon = 1;
+                       break;
+               case 'l':
+                       ctx->mode = PLB_LISTENER;
+                       break;
+               case 'p': {
+                       int port = 0;
+                       port = atoi(optarg);
+                       if (!ctx->geo_id || errno != 0) {
+                               printf("Interval %s is invalid (errno: %d, 
buffer size: %d)\n",
+                                               optarg, errno, 
ctx->bc_interval);
+                               exit(EXIT_FAILURE);
+                       } else {
+                               ctx->bc_addr.sin_port = htons(port);
+                       }
+                       break;
+               }
+               case 'v':
+                       plb_print_version();
+                       break;
+               case 'h':
+                       plb_print_usage(argv);
+                       break;
+               default:
+                       plb_print_usage(argv);
+               }
+       }
+
+}
+
+/**
+ * static void cd_print_usage(char **argv)
+ *
+ * Print usage instructions of client daemon.
+ *
+ * @param argv   pointer to the array of command arguments
+ */
+static void plb_print_usage(char **argv) {
+       fprintf(stderr, "USAGE:\n"
+               "\t%s [options]\n"
+               "\n"
+               "Mode selection\n"
+               "\t-l|--listener            : Listen for broadcasts (default is 
sender).\n"
+               "\n"
+               "Sender options:\n"
+               "\t-d|--bc_addr <ip addr>   : Send location info to this 
address.\n"
+               "\t-i|--bc_interval <int ms>: Broadcast transmit interval.\n"
+               "\t-g|--geo-id <int>        : Router location id.\n"
+               "\n"
+               "Receiver options:\n"
+               "\t-s|--script: execute a shell script when id changes. Provide 
full path.\n"
+               "\n"
+               "General options:\n"
+               "\t-i|--bc_port  <int ms>   : Broadcast dest port.\n"
+               "\t-v|--version             : Print the version number\n"
+               "\t-h|--help                : display this usage\n"
+               "\n", argv[0]);
+
+       exit(EXIT_FAILURE);
+}
+
+/**
+ * Print the version number of client daemon
+ */
+static void plb_print_version(void) {
+
+       fprintf(stderr, "PISA location daemon.\n"
+               "Copyright (C) 2009. Distributed Systems Group, RWTH Aachen 
University.\n");
+
+       /* Print also compile options */
+       fprintf(stderr, "Compile options:\n");
+
+#ifdef CONFIG_PISA_DEBUG
+       fprintf(stderr, " +DEBUG");
+#else
+       fprintf(stderr, " -DEBUG");
+#endif /* CONFIG_PISA_DEBUG */
+
+       fprintf(stderr, "\n");
+
+       exit(EXIT_FAILURE);
+}
+
+/**
+ * Terminate PISA ld by receiving signal
+ *
+ * @param quitcode   signal quit code
+ */
+static void plb_quit(int quitcode) {
+       alarm(0);
+
+       if (quitcode != 0) {
+               switch (quitcode) {
+               case SIGINT:
+                       fprintf(stderr, "WARNING: Got a SIGINT signal.\n");
+                       break;
+               case SIGQUIT:
+                       fprintf(stderr, "WARNING: Got a SIGQUIT signal.\n");
+                       break;
+               case SIGILL:
+                       fprintf(stderr, "WARNING: Got a SIGILL signal.\n");
+                       break;
+               case SIGPIPE:
+                       fprintf(stderr, "WARNING: Got a SIGPIPE signal.\n");
+                       break;
+               case SIGBUS:
+                       fprintf(stderr, "WARNING: Got a SIGBUS signal.\n");
+                       break;
+               case SIGTERM:
+                       fprintf(stderr, "WARNING: Got a SIGTERM signal.\n");
+                       break;
+               default:
+                       fprintf(stderr, "WARNING: Got an unknown 
signal(signum=%d).\n",
+                                       quitcode);
+                       break;
+               }
+               /* cleanup? */
+
+       }
+
+       printf("Quitting PISA location server daemon...\n");
+
+       /* Reinstall default handler for that signal */
+       signal(quitcode, SIG_DFL);
+       exit(EXIT_SUCCESS);
+}
+

Other related posts: