diff --git a/libs/libmicrohttpd/Makefile b/libs/libmicrohttpd/Makefile new file mode 100644 index 0000000..200b863 --- /dev/null +++ b/libs/libmicrohttpd/Makefile @@ -0,0 +1,95 @@ +# +# Copyright (C) 2010-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + + +# This package is just like the one in the package feed. Only newer version. + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libmicrohttpd +PKG_VERSION:=0.9.76 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/libmicrohttpd +PKG_HASH:=f0b1547b5a42a6c0f724e8e1c1cb5ce9c4c35fb495e7d780b9930d35011ceb4c + +PKG_MAINTAINER:=Alexander Couzens +PKG_LICENSE:=LGPL-2.1-or-later +PKG_LICENSE_FILES:=COPYING + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libmicrohttpd/default + SECTION:=libs + CATEGORY:=Libraries + TITLE:=GNU libmicrohttpd is a library that runs an HTTP server. + URL:=https://www.gnu.org/software/libmicrohttpd/ +endef + +define Package/libmicrohttpd-no-ssl +$(call Package/libmicrohttpd/default) + VARIANT:=nossl + DEFAULT_VARIANT:=1 + PROVIDES:=libmicrohttpd +endef + +define Package/libmicrohttpd-ssl +$(call Package/libmicrohttpd/default) + TITLE+= with SSL support + VARIANT:=ssl + DEPENDS:=+libgcrypt +libgnutls +libgpg-error + PROVIDES:=libmicrohttpd +endef + +define Package/libmicrohttpd/description + GNU libmicrohttpd is a small C library that is supposed to make it easy + to run an HTTP server as part of another application. +endef + +CONFIGURE_ARGS += \ + --disable-curl \ + --disable-rpath \ + --disable-doc \ + --disable-examples \ + --disable-poll \ + --enable-epoll \ + --with-pic + +ifeq ($(BUILD_VARIANT),ssl) +CONFIGURE_ARGS += \ + --enable-https \ + --with-gnutls +else +CONFIGURE_ARGS += \ + --disable-https \ + --without-gnutls +endif + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/microhttpd.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmicrohttpd.{so*,a,la} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmicrohttpd.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libmicrohttpd-no-ssl/install + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmicrohttpd.so* $(1)/usr/lib/ +endef + +define Package/libmicrohttpd-ssl/install + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmicrohttpd.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libmicrohttpd-no-ssl)) +$(eval $(call BuildPackage,libmicrohttpd-ssl)) diff --git a/utils/morse-dppd/Makefile b/utils/morse-dppd/Makefile new file mode 100644 index 0000000..f132fb5 --- /dev/null +++ b/utils/morse-dppd/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (C) 2023 Morse Micro +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=morse-dppd +PKG_RELEASE:=1 + +PKG_VERSION:=1.12.4 + +PKG_SOURCE_VERSION:=$(PKG_VERSION) +PKG_SOURCE_URL:=https://github.com/MorseMicro/dpp-daemon.git +PKG_MIRROR_HASH:=fd2011465ab94d22575189b943ca285d6be96ae7e0b5e204fb8d18d1277fbf6e +PKG_SOURCE_PROTO:=git +PKG_HASH:=dd8b39752a632f052ec6706661a93bb4e9d3a8f22a1bad5355ee71fe1996b680 + +MAKE_PATH:=daemon + +include $(INCLUDE_DIR)/package.mk + +# These Flags here are supposed to be inside the dppd's makefile. +# They are there, but, instead of "CFLAGS +=" they've used "CFLAGS ?=" +# Which makes it impossible to just add the OpenWrt specific flags. +# so, We have to redefine all of them here and append them to OpenWrt CFLAGS. +TARGET_CFLAGS += \ +-I$(PKG_BUILD_DIR)/$(MAKE_PATH) \ +-I$(PKG_BUILD_DIR)/$(MAKE_PATH)/include \ +-I$(PKG_BUILD_DIR)/$(MAKE_PATH)/backend/wpa_ctrl \ +-I$(PKG_BUILD_DIR)/$(MAKE_PATH)/backend/wpa_ctrl/utils \ +-I$(PKG_BUILD_DIR)/$(MAKE_PATH)/backend/wpa_ctrl/common \ +-I$(STAGING_DIR)/usr/include/libnl3 \ +-DHOSTAPD \ +-DHOSTAPD_DUMP_STATE \ +-DCONFIG_CTRL_IFACE_UNIX \ +-DCONFIG_CTRL_IFACE \ +-DCONFIG_RSN_PREAUTH \ +-DCONFIG_DRIVER_HOSTAP \ +-DCONFIG_DRIVER_NL80211 \ +-DCONFIG_ERP \ +-DEAP_SERVER_MD5 \ +-DEAP_SERVER_TLS \ +-DEAP_SERVER_PEAP \ +-DEAP_SERVER_TTLS \ +-DEAP_SERVER_MSCHAPV2 \ +-DEAP_SERVER_GTC \ +-DEAP_SERVER_IDENTITY \ +-DEAP_SERVER \ +-DPKCS12_FUNCS \ +-DEAP_TLS_FUNCS \ +-DTLS_DEFAULT_CIPHERS=\""DEFAULT:!EXP:!LOW"\" \ +-DCONFIG_DES \ +-DCONFIG_SHA256 \ +-DCONFIG_IPV6 \ +-DNEED_AP_MLME + +define Package/morse-dppd + SECTION:=Utilities + CATEGORY:=Utilities + TITLE:=MorseMicro 802.11ah DPP Daemon + MAINTAINER:=Morse Micro + DEPENDS:=dppd-creds +libnl +libnl-genl +libopenssl +libncurses +libmicrohttpd-ssl +avahi-utils +endef + +define Package/morse-dppd/description + MorseMicro 802.11ah Device Provisioning Protocol Daemon +endef + +define Package/morse-dppd/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/build/dppd $(1)/usr/bin/ + $(INSTALL_BIN) ./files/etc/init.d/dppd $(1)/etc/init.d/ +endef + +$(eval $(call BuildPackage,morse-dppd)) diff --git a/utils/morse-dppd/files/etc/init.d/dppd b/utils/morse-dppd/files/etc/init.d/dppd new file mode 100755 index 0000000..fe42a2d --- /dev/null +++ b/utils/morse-dppd/files/etc/init.d/dppd @@ -0,0 +1,79 @@ +#!/bin/sh /etc/rc.common + +START=90 +STOP=01 +USE_PROCD=1 +SERVICE=dppd + +find_morse_device() { + local device=$1 + local type_morse + config_get type_morse $device type + + if [ "$type_morse" == "morse" ]; then + morse_radio=$1 + return 1 + fi +} + +find_iface_ap_key() { + local iface=$1 + local radio=$2 + local dev_iface= + config_get dev_iface $iface device + + [ "$dev_iface" != "$radio" ] && return; + + local is_ap= + config_get is_ap $iface mode + + [ "$is_ap" != "ap" ] && return; + + local encryption= + config_get encryption $iface encryption + + [ "$encryption" != "sae" ] && return; + + config_get key $iface key +} + +get_encryption_key() { + config_load wireless + config_foreach find_morse_device wifi-device + config_foreach find_iface_ap_key wifi-iface $morse_radio +} + +start_dppd() { + procd_open_instance + procd_set_param command dppd --passphrase="$1" + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_append_param command --http-secrets=/etc/dppd/auth_secrets.txt + procd_append_param command --tls-cert=/etc/dppd/server.pem --tls-key=/etc/dppd/server.key + procd_append_param command --configurator-key=/etc/dppd/key.pem --configurator-private-key=/etc/dppd/ppkey.pem + procd_append_param command daemon + procd_set_param limits as="15000000 15000000" + procd_set_param respawn 3600 5 50 + procd_close_instance +} + +start_service() { + get_encryption_key + if [ -z "$key" ]; then + logger -t $SERVICE -p daemon.crit "No AP on morse device with encryption as SAE" + return 1 + fi + start_dppd $key +} + + +reload_service() { + stop + # Wait until hostapd stops (otherwise we reconnect to old hostapd with the wrong info, + # then lose the connection, then segfault when we find the new hostapd). + ( sleep 5; start ) & +} + +service_triggers() { + procd_add_reload_trigger wireless +} diff --git a/utils/morse-dppd/patches/001-find-hostapd_s1g.patch b/utils/morse-dppd/patches/001-find-hostapd_s1g.patch new file mode 100644 index 0000000..bbaf621 --- /dev/null +++ b/utils/morse-dppd/patches/001-find-hostapd_s1g.patch @@ -0,0 +1,13 @@ +diff --git a/daemon/dppd.c b/daemon/dppd.c +index a524bd2..3885bc4 100644 +--- a/daemon/dppd.c ++++ b/daemon/dppd.c +@@ -122,7 +122,7 @@ find_ctrl_if_path() + { + while ((dir_data = readdir(root_dir)) != NULL) + { +- if (strstr(dir_data->d_name, "hostapd")) ++ if (strstr(dir_data->d_name, "hostapd_s1g")) + { + + if (found)