User Tools

Site Tools


misc:ecmh

Table of Contents

Install ecmh on OpenWrt

This page is a small memo about how to install ecmh in openwrt. It is completely experimental and may not work.

See also ecmh official website

Sources

Sources can be found on GitHub.

I found a bug in the sources, it needs to be corrected.

diff --git a/src/interfaces.c b/src/interfaces.c
index cc80423..6794c23 100755
--- a/src/interfaces.c
+++ b/src/interfaces.c
@@ -230,12 +230,20 @@ struct intnode *int_create(unsigned int ifindex, bool tunnel)
                close(sock);
                return NULL;
        }
+
+/* Modified because probably buggy
 #ifdef ECMH_BPF
        memcpy(&intn->name, &ifreq.ifr_name, sizeof(intn->name));
 #else
        memcpy(&ifreq.ifr_name, &intn->name, sizeof(ifreq.ifr_name));
 #endif
+*/
 
+/* Added */
+#ifdef SIOCGIFNAME
+       memcpy(intn->name, ifreq.ifr_name, sizeof(ifreq.ifr_name));
+#endif
+/* */
        /* Get the MTU size of this interface */
        /* We will use that for fragmentation */
        if (ioctl(sock, SIOCGIFMTU, &ifreq) != 0)

Makefile

The Makefile almost works for OpenWrt. It just needs a few modifications.

diff --git a/src/Makefile b/src/Makefile
index a13c969..b3784d3 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,6 +33,7 @@ endif
 CFLAGS = $(WARNS) $(EXTRA) -D_GNU_SOURCE -D'ECMH_VERSION="$(ECMH_VERSION)"' -D'ECMH_GITHASH="$(ECMH_GITHASH)"' $(ECMH_OPTIONS)
 LDFLAGS        = $(ECMH_LDFREEBSD)
 LINK    = @echo "* Linking $@"; $(CC) $(CFLAGS) $(LDFLAGS)
+LDLIBS = -lrt
 
 -include $(OBJS:.o=.d)
 
@@ -55,7 +56,7 @@ depend: clean
 ecmh:  $(DEPS) $(OBJS)
        $(LINK) -o $@ $(OBJS) $(LDLIBS)
 ifeq ($(shell echo $(ECMH_OPTIONS) | grep -c "DEBUG"),0)
-       @strip $@
+       #@strip $@
 endif
 
 clean:
diff --git a/tools/mtrace6/Makefile b/tools/mtrace6/Makefile
index 1693927..a200df4 100755
--- a/tools/mtrace6/Makefile
+++ b/tools/mtrace6/Makefile
@@ -39,7 +39,7 @@ depend: clean
 mtrace6: $(DEPS) $(OBJS) $(INCS)
        $(LINK) -o $@ $(OBJS) $(LDLIBS)
 ifeq ($(shell echo $(ECMH_OPTIONS) | grep -c "DEBUG"),0)
-       @strip $@
+       #@strip $@
 endif
 
 clean:

Create feed

You need to create a feed. Here is an exemple that uses a local copy of the git repository. I also put ecmh.init in the feed directory (in files), so that I could modify and test it easily.

include $(TOPDIR)/rules.mk
 
PKG_NAME:=ecmh
#PKG_SOURCE_VERSION:=2
#PKG_SOURCE_VERSION:=4b27c8a65c6a698a01cd6bab0fe49c7e018525c9
PKG_SOURCE_VERSION:=<git commit id>
PKG_VERSION:=2013-12-12-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
 
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=/path/to/the/local/repository
PKG_MAINTAINER:=Jeroen Massar <jeroen@massar.ch>
 
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
 
include $(INCLUDE_DIR)/package.mk
 
define Package/ecmh
  SECTION:=ipv6
  CATEGORY:=IPv6
  TITLE:=ecmh
  URL:=https://github.com/massar/ecmh/
  DEPENDS:=+ip +librt
  DEPENDS+=+@IPV6
endef
 
define Package/ecmh/description
ecmh openwrt package
endef
 
define Package/ecmh/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/ecmh $(1)/usr/sbin/ecmh
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mtrace6/mtrace6 $(1)/usr/sbin/mtrace6
 
	$(INSTALL_DIR) $(1)/etc/init.d/
	$(INSTALL_BIN) files/ecmh.init $(1)/etc/init.d/ecmh
endef
 
$(eval $(call BuildPackage,ecmh))

Run it

Use -f to run it in foreground.

ecmh -i <upstream interface>
misc/ecmh.txt · Last modified: 2016/09/05 16:15 (external edit)