Mobile Multimedia Laboratory



P2PWNC: Peer-to-peer Wireless Network Confederation RI - Documentation





The instructions that follow can help you add the P2PWNC access point protocol module on the Linksys WRT54GS router platform. We assume that the Linksys WRT54GS firmware sources have been downloaded and extracted to the srcpath directory (replace srcpath with the directory of your choice). After that, one has to take the following steps:

  • Download the P2PWNC libraries, on which the P2PWNC access point software depends.

  • Extract the P2PWNC libraries package inside
    [srcpath]/release/src/router.
    The directory where the software is should be renamed to "p2pwnc-libs"

  • Download the P2PWNC access point software and extract it inside
    [srcpath]/release/src/router.
    Then, rename the folder to p2pwnc-ap.

  • The ap program reads NVRAM variables and builds a temporary configuration file. These variables can be remotely manipulated using the configuration server available for download here After downloading the Linksys WRT54GS remote configuration server, extract it to
    [srcpath]/release/src/router.
    and ename the folder to wrt-conf-srv. Note that this step is optional. This server is not mandatory for running the P2PWNC software. This program is only a utility for configuring the software by remotely manipulating NVRAM variables. The same goal can be achieved by connecting to the router via SSH and using the router's
    nvram
    command line utility. The latter assumes that you have installed an SSH daemon (e.g. Dropbear) on the Linksys box.

  • Configure the P2PWNC libraries software using the following command:

    CC=mipsel-uclibc-gcc ./configure --enable-cryptosystem=ecc --enable-headers=no
    --enable-rdb=no --host=mipsel-linux --build=i686-pc-linux-gnu --with-openssl=

    The above command assumes that you will be using OpenSSL 0.9.8. Instructions on porting this OpenSSL version to the Linksys WRT54GS router platform can be found here.

  • Configure the P2PWNC access point software using the following command:

    CC=mipsel-uclibc-gcc ./configure --enable-tlog --host=mipsel-linux --build=i686-pc-linux-gnu --with-p2pwnc-libs=


  • In case you wish to install the remote configuration server
    (wrt-conf-srv),
    use the following command:

    CC=mipsel-uclibc-gcc ./configure --host=mipsel-linux --build=i686-pc-linux-gnu


  • Add the following to
    [srcpath]/release/src/cy_conf.h

    #define P2PWNC_LIBS_SUPPORT 1
    #define CONFIG_P2PWNC_LIBS y
    #define P2PWNC_AP_SUPPORT 1
    #define CONFIG_P2PWNC_AP y

    If you are building
    wrt-conf-srv
    , also add the following:

    #define WRT_CONF_SRV_SUPPORT 1
    #define CONFIG_WRT_CONF_SRV y


  • Add the following lines to
    [srcpath]/release/src/cy_conf.mak

    P2PWNC_LIBS_SUPPORT=1
    CONFIG_P2PWNC_LIBS=y
    P2PWNC_AP_SUPPORT=1
    CONFIG_P2PWNC_AP=y

    As in the previous cases, if you wish to include the (optional) wrt-conf-srv package, also add the following:

    WRT_CONF_SRV_SUPPORT=1
    CONFIG_WRT_CONF_SRV=y


  • Add the following blocks to
    [srcpath]/release/src/router/config/Config

    config CONFIG_P2PWNC_LIBS
    bool "P2PWNC protocol libraries"
    default y
    help
    P2PWNC v0.0.1

    config CONFIG_P2PWNC_AP
    bool "P2PWNC protocol access point server"
    default y
    help
    P2PWNC v0.0.1

    For the wrt-conf-srv package (optional), add the following:

    config CONFIG_WRT_CONF_SRV
    bool "Linksys WRT54GS remote configuration server"
    default y
    help
    wrt-conf-srv v0.0.1


  • Now, the router's Makefile needs to be modified so that the additional modules are built and included in the router's firmware image. The following need to be inserted to
    [srcpath]/release/src/router/Makefile
    :
    • In the "configuration" section, the following lines should be added:

      obj-$(CONFIG_P2PWNC_LIBS) += p2pwnc-libs
      obj-$(CONFIG_P2PWNC_AP) += p2pwnc-ap

      To build/install
      wrt-conf-srv
      , also add this line:

      obj-$(CONFIG_WRT_CONf_SRV) += wrt-conf-srv


    • In the section where the rules appear, the following rules must be added:

      p2pwnc-libs: nvram shared openssl
          $(MAKE) -C p2pwnc-libs CFLAGS="-I../../openssl/include -I../openssl/include -I$(SRCBASE)/include" LDFLAGS="-L$(INSTALLDIR)/openssl/usr/lib"

      p2pwnc-ap: p2pwnc-libs-install nvram shared openssl
          $(MAKE) -C ./p2pwnc-ap/ap CFLAGS="-I../../openssl/include -I../openssl/include -I$(SRCBASE)/include -I../../p2pwnc-libs/include" LDFLAGS="-L$(INSTALLDIR)/p2pwnc-libs/usr/lib -Wl,-rpath-link -Wl,$(INSTALLDIR)/openssl/usr/lib"

          $(MAKE) -C ./p2pwnc-ap/tlog KMOD_DIR=$(LINUXDIR) KERNELVERSION="2.4" modules

      p2pwnc-libs-install:
          install -D p2pwnc-libs/proto/libpwnc.so $(INSTALLDIR)/p2pwnc-libs/usr/lib/libpwnc.so
          $(STRIP) $(INSTALLDIR)/p2pwnc-libs/usr/lib/libpwnc.so
          install -D p2pwnc-libs/3rdparty/lib3p.so $(INSTALLDIR)/p2pwnc-libs/usr/lib/lib3p.so
          $(STRIP) $(INSTALLDIR)/p2pwnc-libs/usr/lib/lib3p.so

      p2pwnc-ap-install: p2pwnc-libs-install
          install -D p2pwnc-ap/ap/cmd_handler $(INSTALLDIR)/p2pwnc-ap/usr/bin/cmd_handler
          $(STRIP) $(INSTALLDIR)/p2pwnc-ap/usr/bin/cmd_handler
          install -D p2pwnc-ap/ap/ap $(INSTALLDIR)/p2pwnc-ap/usr/bin/ap
          $(STRIP) $(INSTALLDIR)/p2pwnc-ap/usr/bin/ap
          $(MAKE) -C p2pwnc-ap/tlog KERNELVERSION="2.4" prefix="$(INSTALLDIR)/p2pwnc-ap/lib/modules/2.4.20" KMOD_DIR=$(LINUXDIR) install

      p2pwnc-clean:
          $(MAKE) -C p2pwnc-libs clean
          $(MAKE) -C p2pwnc-ap clean

      The
      KERNELVERSION
      and
      KMOD_DIR
      are necessary so that the traffic logging module is built for the correct kernel version. The process of building kernel modules has changed in 2.6 kernels. The Linux distribution available from Linksys uses a 2.4 kernel, while OpenWRT comes with a 2.6 kernel.

      It should also be noted that such flags (e.g. CFLAGS, LDFLAGS, etc) can be passed when configuring the programs instead.

      Again, for the wrt-conf-srv package (optional), add:

      wrt-conf-srv: nvram
          $(MAKE) -C wrt-conf-srv CFLAGS="-I$(SRCBASE)/include/" LDFLAGS="-L$(TOP)/nvram"

      wrt-conf-srv-install:
          $(MAKE) -C wrt-conf-srv prefix="$(INSTALLDIR)/wrt-conf-srv/usr install

      wrt-conf-srv-clean:
          $(MAKE) -C wrt-conf-srv clean


  • The router's startup functions are controlled by the file
    services.c
    located in the
    [srcpath]/release/src/router/rc/
    directory. functions. Therefore, since we want to startup the ap software as soon as the router is powered up, we have to add/modify the appropriate routines. A patch adding the necessary functionality so that when the router is powered up, configuration information about the ap program (e.g public key, repository address, etc) is read from the NVRAM, a temporary configuration file is built, the traffic logging module is insmodded, the iptables command handling process is started and, finally, the ap program is started using configuration from this temporary file will soon be available. Also, this patch will add functionality for starting up the Dropbear SSH daemon (as described here).