# Copyright (C) 2006 OpenWrt.org # # This is a free software licensed under the GNU General Public License v2. # See / LICENSE for more information. # # $ Id: Makefile 6008 2007-01-06 18: 39: 10Z nbd $ include $ (TOPDIR) /rules.mk PKG_NAME: = hanstunnel PKG_VERSION: = 0.4.3 PKG_RELEASE: = 1 PKG_BUILD_DIR: = $ (BUILD_DIR) / $ (PKG_NAME) - $ (PKG_VERSION) include $ (INCLUDE_DIR) /package.mk define Package / hanstunnel SECTION: = net CATEGORY: = Network SUBMENU: = Firewall Tunnel DEPENDS: = + libstdcpp + kmod-tun TITLE: = Hans IP over ICMP URL: = http: //code.gerade.org/hans/ endef define Package / hanstunnel / description Hans makes it possible to tunnel IPv4 through ICMP echo packets, so you could call it a ping tunnel. This can be useful when you find yourself in the situation that your Internet access is firewalled, but pings are allowed. endef endef define Build / Prepare echo PREPARE PREPARE mkdir -p $ (PKG_BUILD_DIR) cp -r ./src/* $ (PKG_BUILD_DIR) / endef define Build / Compile $ (MAKE) -C $ (PKG_BUILD_DIR) GCC = $ (TARGET_CC) GPP = $ (TARGET_CXX) endef define Package / hanstunnel / install $ (INSTALL_DIR) $ (1) / usr / sbin $ (INSTALL_BIN) $ (PKG_BUILD_DIR) / hans $ (1) / usr / sbin / $ (INSTALL_DIR) $ (1) /etc/init.d $ (INSTALL_BIN) ./files/hans.init $ (1) /etc/init.d/hans $ (INSTALL_DIR) $ (1) / etc / config $ (INSTALL_CONF) ./files/hans.config $ (1) / etc / config / hans endef $ (eval $ (call BuildPackage, hanstunnel))
#LDFLAGS + = `sh osflags ld $ (MODE)` CFLAGS + = -c -g -DLINUX -DHAVE_LINUX_IF_TUN_H TUN_DEV_FILE = src / tun_dev_linux.c #GCC = gcc #GPP = g ++ .PHONY: directories all: hans directories: build_dir build_dir: mkdir -p build tunemu.o: directories build / tunemu.o hans: directories build / tun.o build / sha1.o build / main.o build / client.o build / server.o build / auth.o build / worker.o build / time.o build / tun_dev.o build / echo.o build / exception.o build / utility.o $ (GPP) -o hans build / tun.o build / sha1.o build / main.o build / client.o build / server.o build / auth.o build / worker.o build / time.o build / tun_dev .o build / echo.o build / exception.o build / utility.o $ (LDFLAGS) build / utility.o: src / utility.cpp src / utility.h $ (GPP) -c src / utility.cpp -o $ @ -o $ @ $ (CFLAGS) build / exception.o: src / exception.cpp src / exception.h $ (GPP) -c src / exception.cpp -o $ @ $ (CFLAGS) build / echo.o: src / echo.cpp src / echo.h src / exception.h $ (GPP) -c src / echo.cpp -o $ @ $ (CFLAGS) build / tun.o: src / tun.cpp src / tun.h src / exception.h src / utility.h src / tun_dev.h $ (GPP) -c src / tun.cpp -o $ @ $ (CFLAGS) build / tun_dev.o: $ (GCC) -c $ (TUN_DEV_FILE) -o build / tun_dev.o -o $ @ $ (CFLAGS) build / sha1.o: src / sha1.cpp src / sha1.h $ (GPP) -c src / sha1.cpp -o $ @ $ (CFLAGS) build / main.o: src / main.cpp src / client.h src / server.h src / exception.h src / worker.h src / auth.h src / time.h src / echo.h src / tun. h src / tun_dev.h $ (GPP) -c src / main.cpp -o $ @ $ (CFLAGS) build / client.o: src / client.cpp src / client.h src / server.h src / exception.h src / config.h src / worker.h src / auth.h src / time.h src / echo. h src / tun.h src / tun_dev.h $ (GPP) -c src / client.cpp -o $ @ $ (CFLAGS) build / server.o: src / server.cpp src / server.h src / client.h src / utility.h src / config.h src / worker.h src / auth.h src / time.h src / echo. h src / tun.h src / tun_dev.h $ (GPP) -c src / server.cpp -o $ @ $ (CFLAGS) build / auth.o: src / auth.cpp src / auth.h src / sha1.h src / utility.h $ (GPP) -c src / auth.cpp -o $ @ $ (CFLAGS) build / worker.o: src / worker.cpp src / worker.h src / tun.h src / exception.h src / time.h src / echo.h src / tun_dev.h src / config.h $ (GPP) -c src / worker.cpp -o $ @ $ (CFLAGS) build / time.o: src / time.cpp src / time.h $ (GPP) -c src / time.cpp -o $ @ $ (CFLAGS) clean: rm -f build / tun.o build / sha1.o build / main.o build / client.o build / server.o build / auth.o build / worker.o build / time.o build / tun_dev.o build / echo.o build / exception.o build / utility.o build / tunemu.o hans rm -df build build / tunemu.o: src / tunemu.h src / tunemu.c $ (GCC) -c src / tunemu.c -o build / tunemu.o
$ ls -R custom custom: hanstunnel custom / hanstunnel: files makefile src custom / hanstunnel / files: hans.config hans.init custom / hanstunnel / src: Makefile osflags src custom / hanstunnel / src / src: auth.cpp client.h echo.h main.cpp sha1.cpp time.cpp tun_dev_darwin_emu.c tun_dev.h tun_dev_svr4.c tun.h worker.cpp auth.h config.h exception.cpp server.cpp sha1.h time.h tun_dev_freebsd.c tun_dev_linux.c tunemu.c utility.cpp worker.h client.cpp echo.cpp exception.h server.h sha1_license.txt tun.cpp tun_dev_generic.c tun_dev_openbsd.c tunemu.h utility.h
$ make package / feeds / packages / hanstunnel / compile -j5 make [1] package / feeds / packages / hanstunnel / compile make [2] -C package / kernel / linux compile make [2] -C package / libs / toolchain compile make [2] -C custom / hanstunnel compile
uint16_t Echo :: icmpChecksum (const char * data, int length) { uint16_t * data16 = (uint16_t *) data; uint32_t sum = 0; for (sum = 0; length> 1; length - = 2) sum + = * data16 ++; if (length == 1) { unsigned char tail [2] = {* (unsigned char *) data16, 0}; sum + = * (uint16_t *) tail; } while (sum >> 16) sum = (sum >> 16) + (sum & 0xffff); return ~ sum; }
Source: https://habr.com/ru/post/211284/