Skip to contentSkip to conversation

igd2-for-linux: new package

PATCH Superseded Fabrice Fontaine 2 participants 3 messages Jul 19, 2016 – Jul 21, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 igd2-for-linux: new package

This is The Linux UPnP Internet Gateway Device 2. It is modified from the original Linux UPnP Internet Gateway Device
[http://linux-igd.sourceforge.net/] according to UPnP InternetGatewayDevice:2 specifications.

It implements the UPnP Internet Gateway Device version 2 specification (IGDv2) and allows UPnP aware clients, such as MSN Messenger, Azureus or Miranda to work properly from behind a NAT firewall.

Please edit /etc/upnpd.conf before using upnpd!

https://github.com/ffontaine/igd2-for-linux

---
Changes v2 -> v3 (after review of Romain Naour):
- Remove iptables from IGD2_FOR_LINUX_DEPENDENCIES as this is a runtime dependency
- Remove CFLAGS definition from IGD2_FOR_LINUX_BUILD_CMDS as it's already a part of TARGET_CONFIGURE_OPTS
- Remove BINDIR and MANDIR from IGD2_FOR_LINUX_BUILD_CMDS as they're not defined in Makefile
- Use -D option and specify a full destination path when installing files

Changes v1 -> v2 (after review of Romain Naour):
- Do not use HAVE_LIBIPTC as it doesn't work with musl toolchain due to mixed userspace and kernel headers and some undeclared IPPROTO_TCP/IPPROTO_UDP variables. libiptc is not a public and stable API for iptables:
http://www.netfilter.org/documentation/FAQ/netfilter-faq-4.html

 package/Config.in                          |  1 +
 package/igd2-for-linux/Config.in           | 25 ++++++++++++
 package/igd2-for-linux/S99upnpd            | 42 ++++++++++++++++++++
 package/igd2-for-linux/igd2-for-linux.hash |  2 +
 package/igd2-for-linux/igd2-for-linux.mk   | 64 ++++++++++++++++++++++++++++++
 package/igd2-for-linux/upnpd.service       | 12 ++++++
 6 files changed, 146 insertions(+)
 create mode 100644 package/igd2-for-linux/Config.in
 create mode 100644 package/igd2-for-linux/S99upnpd
 create mode 100644 package/igd2-for-linux/igd2-for-linux.hash
 create mode 100644 package/igd2-for-linux/igd2-for-linux.mk
 create mode 100644 package/igd2-for-linux/upnpd.service
package/Config.in +1 -0
index f86e1ef..8062437 100644
@@ -1443,6 +1443,7 @@ menu "Networking applications"
 	source "package/ifplugd/Config.in"
 	source "package/iftop/Config.in"
 	source "package/ifupdown/Config.in"
+	source "package/igd2-for-linux/Config.in"
 	source "package/igh-ethercat/Config.in"
 	source "package/igmpproxy/Config.in"
 	source "package/inadyn/Config.in"
package/igd2-for-linux/Config.in new file +25 -0
new file mode 100644
index 0000000..9022536
@@ -0,0 +1,25 @@
+config BR2_PACKAGE_IGD2_FOR_LINUX
+	bool "igd2-for-linux"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_USE_WCHAR
+	select BR2_PACKAGE_IPTABLES # runtime
+	select BR2_PACKAGE_LIBUPNP
+	help
+	  This is The Linux UPnP Internet Gateway Device 2. It is
+	  modified from the original Linux UPnP Internet Gateway Device
+	  [http://linux-igd.sourceforge.net/] according to UPnP
+	  InternetGatewayDevice:2 specifications.
+
+	  It implements the UPnP Internet Gateway Device version 2
+	  specification (IGDv2) and allows UPnP aware clients, such as
+	  MSN Messenger, Azureus or Miranda to work properly from behind
+	  a NAT firewall.
+
+	  Please edit /etc/upnpd.conf before using upnpd!
+
+	  https://github.com/ffontaine/igd2-for-linux
+
+comment "igd2-for-linux needs a toolchain w/ threads and wchar"
+	depends on BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR
package/igd2-for-linux/S99upnpd new file +42 -0

42 lines not on this page · raw message

package/igd2-for-linux/igd2-for-linux.hash new file +2 -0
new file mode 100644
index 0000000..a46fe5f
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256	a8edc4c14aa104dcffa79d1f3057b8b9c5cef0f8f43901f61e306120a4efe01f	igd2-for-linux-v1.1.tar.gz
package/igd2-for-linux/igd2-for-linux.mk new file +64 -0

64 lines not on this page · raw message

package/igd2-for-linux/upnpd.service new file +12 -0
new file mode 100644
index 0000000..479f5b2
@@ -0,0 +1,12 @@
+[Unit]
+Description=UPnP Internet Gateway Device version 2 daemon
+After=network.target
+
+[Service]
+ExecStartPre=/sbin/route add -net 239.0.0.0 netmask 255.0.0.0 eth0
+ExecStart=/usr/sbin/upnpd -f eth0 eth0
+Restart=always
+ExecStopPost=/sbin/route del -net 239.0.0.0 netmask 255.0.0.0 eth0
+
+[Install]
+WantedBy=multi-user.target
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 igd2-for-linux: new package

Hello,

Quoted 10 lines · Fabrice Fontaine

This is The Linux UPnP Internet Gateway Device 2. It is modified from the original Linux UPnP Internet Gateway Device
[http://linux-igd.sourceforge.net/] according to UPnP InternetGatewayDevice:2 specifications.

It implements the UPnP Internet Gateway Device version 2 specification (IGDv2) and allows UPnP aware clients, such as MSN Messenger, Azureus or Miranda to work properly from behind a NAT firewall.

Quoted 5 lines

Please edit /etc/upnpd.conf before using upnpd!

https://github.com/ffontaine/igd2-for-linux

Thanks for this new iteration. It looks pretty good, but I have both some questions and comments, see below.

package/igd2-for-linux/S99upnpd line 7

Quoted 13 lines
package/igd2-for-linux/S99upnpd new file +7 -0
new file mode 100644
index 0000000..3a5b20a
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+NAME=upnpd
+PIDFILE=/var/run/$NAME.pid
+DAEMON=/usr/sbin/$NAME
+LAN=eth0
+WAN=eth0

So we really need to hardcode the interface here? This means it will not work out of the box for everyone, but maybe this is something we cannot do anything about.

But at least, we should source /etc/default/upnpd to allow the user to easily override those values.

package/igd2-for-linux/S99upnpd line 12

Quoted 5 lines
package/igd2-for-linux/S99upnpd new file +5 -0
+DAEMON_ARGS="-f $WAN $LAN"
+
+start() {
+	printf "Starting $NAME: "
+	route add -net 239.0.0.0 netmask 255.0.0.0 $LAN

Should this be configurable? I'm worried about other init scripts doing the same route addition.

Quoted 7 lines
package/igd2-for-linux/S99upnpd new file +7 -0
+IGD2_FOR_LINUX_VERSION = v1.1
+IGD2_FOR_LINUX_SITE = \
+	$(call github,ffontaine,igd2-for-linux,$(IGD2_FOR_LINUX_VERSION))
+
+IGD2_FOR_LINUX_LICENSE = GPLv2
+IGD2_FOR_LINUX_LICENSE_FILES = linuxigd2/doc/LICENSE
+

package/igd2-for-linux/S99upnpd line 29

Quoted 10 lines
package/igd2-for-linux/S99upnpd new file +10 -0
+IGD2_FOR_LINUX_DEPENDENCIES = libupnp
+
+IGD2_FOR_LINUX_BUILD_DIR = $(@D)/linuxigd2
+IGD2_FOR_LINUX_CONF_DIR = $(IGD2_FOR_LINUX_BUILD_DIR)/configs
+
+define IGD2_FOR_LINUX_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(IGD2_FOR_LINUX_BUILD_DIR) \
+	$(TARGET_CONFIGURE_OPTS) \
+	LIBUPNP_PREFIX="$(STAGING_DIR)/usr" \
+	all

Please indent the continuation lines:

	$(TARGET_MAKE_ENV) $(MAKE) -C $($(IGD2_FOR_LINUX_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		... \
		...
Quoted 15 lines
package/igd2-for-linux/S99upnpd new file +15 -0
+endef
+
+define IGD2_FOR_LINUX_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(IGD2_FOR_LINUX_BUILD_DIR)/bin/upnpd \
+		$(TARGET_DIR)/usr/sbin/upnpd
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/ligd.png \
+		$(TARGET_DIR)/etc/linuxigd/ligd.png
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/dummy.xml \
+		$(TARGET_DIR)/etc/linuxigd/dummy.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gateconnSCPD.xml \
+		$(TARGET_DIR)/etc/linuxigd/gateconnSCPD.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gatedesc1.xml \
+		$(TARGET_DIR)/etc/linuxigd/gatedesc1.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gatedesc.xml \
+		$(TARGET_DIR)/etc/linuxigd/gatedesc.xml

package/igd2-for-linux/S99upnpd

Quoted 10 lines
package/igd2-for-linux/S99upnpd new file +10 -0
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gateEthlcfgSCPD.xml \
+		$(TARGET_DIR)/etc/linuxigd/gateEthlcfgSCPD.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gateicfgSCPD.xml \
+		$(TARGET_DIR)/etc/linuxigd/gateicfgSCPD.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/lanhostconfigSCPD.xml \
+		$(TARGET_DIR)/etc/linuxigd/lanhostconfigSCPD.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/wanipv6fwctrlSCPD.xml \
+		$(TARGET_DIR)/etc/linuxigd/wanipv6fwctrlSCPD.xml
+	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/upnpd.conf \
+		$(TARGET_DIR)/etc/upnpd.conf

Can you write instead:

	$(INSTALL) -D -m 0755 $(IGD2_FOR_LINUX_BUILD_DIR)/bin/upnpd \
		$(TARGET_DIR)/usr/sbin/upnpd
	$(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/upnpd.conf \
		$(TARGET_DIR)/etc/upnpd.conf
	mkdir -p $(TARGET_DIR)/etc/linuxigd/
	cp -dpfr $(IGD2_FOR_LINUX_CONF_DIR)/*.{xml,png} \
		$(TARGET_DIR)/etc/linuxigd/

or alternatively, if you really want to copy explicitly each file one by one to /etc/linuxigd, define a variable like IGD2_FOR_LINUX_ETC_LINUXIGD_FILES, that lists all the filenames, and then use a foreach loop.

package/igd2-for-linux/S99upnpd

Quoted 2 lines
package/igd2-for-linux/S99upnpd new file +2 -0
+define IGD2_FOR_LINUX_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 0644 package/domoticz/upnpd.service \

Hum, really package/domoticz ?

Quoted 13 lines
package/igd2-for-linux/S99upnpd new file +7 -0
+		$(TARGET_DIR)/usr/lib/systemd/system/upnpd.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -sf ../../../../usr/lib/systemd/system/upnpd.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/upnpd.service
+endef
+
+$(eval $(generic-package))
package/igd2-for-linux/upnpd.service new file +0 -0
new file mode 100644
index 0000000..479f5b2

package/igd2-for-linux/upnpd.service line 9

Quoted 9 lines
package/igd2-for-linux/upnpd.service new file +9 -0
@@ -0,0 +1,12 @@
+[Unit]
+Description=UPnP Internet Gateway Device version 2 daemon
+After=network.target
+
+[Service]
+ExecStartPre=/sbin/route add -net 239.0.0.0 netmask 255.0.0.0 eth0
+ExecStart=/usr/sbin/upnpd -f eth0 eth0
+Restart=always
+ExecStopPost=/sbin/route del -net 239.0.0.0 netmask 255.0.0.0 eth0

Same questions about the customization of eth0 and 239.0.0.0.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 igd2-for-linux: new package

Hello Thomas,

Thanks for your review, I sent a new patch a few minutes ago.

Concerning your comment on interfaces, I will follow your advise and add a file to source them from /etc/default/upnpd because I can not retrieve them from buildroot environment variables. An other option would be to reuse the BR2_SYSTEM_DHCP variable (if it is non empty) for, at least, the LAN interface.

Concerning your comment on the route, I will disable it by default and add a comment about it. I will simply comment the ExecStartPre and ExecPostPre commands in systemd script as it seems impossible to use conditions on variables with systemd.

Best Regards,

Fabrice

2016-07-20 23:07 GMT+02:00 Thomas Petazzoni <
[email protected]>:

Quoted 156 lines

Hello,

Quoted 10 lines · Fabrice Fontaine

This is The Linux UPnP Internet Gateway Device 2. It is modified from the original Linux UPnP Internet Gateway Device
[http://linux-igd.sourceforge.net/] according to UPnP InternetGatewayDevice:2 specifications.

It implements the UPnP Internet Gateway Device version 2 specification (IGDv2) and allows UPnP aware clients, such as MSN Messenger, Azureus or Miranda to work properly from behind a NAT firewall.

Quoted 5 lines

Please edit /etc/upnpd.conf before using upnpd!

https://github.com/ffontaine/igd2-for-linux

Thanks for this new iteration. It looks pretty good, but I have both some questions and comments, see below.

Review

Quoted 1 line
(quoted diff) +0 -0

b/package/igd2-for-linux/S99upnpd

package/igd2-for-linux/S99upnpd line 7

Quoted 12 lines

new file mode 100644
index 0000000..3a5b20a

package/igd2-for-linux/S99upnpd new file +7 -0
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+NAME=upnpd
+PIDFILE=/var/run/$NAME.pid
+DAEMON=/usr/sbin/$NAME
+LAN=eth0
+WAN=eth0

So we really need to hardcode the interface here? This means it will not work out of the box for everyone, but maybe this is something we cannot do anything about.

But at least, we should source /etc/default/upnpd to allow the user to easily override those values.

package/igd2-for-linux/S99upnpd line 12

Quoted 5 lines
package/igd2-for-linux/S99upnpd new file +5 -0
+DAEMON_ARGS="-f $WAN $LAN"
+
+start() {
+     printf "Starting $NAME: "
+     route add -net 239.0.0.0 netmask 255.0.0.0 $LAN

Should this be configurable? I'm worried about other init scripts doing the same route addition.

Quoted 7 lines
package/igd2-for-linux/S99upnpd new file +7 -0
+IGD2_FOR_LINUX_VERSION = v1.1
+IGD2_FOR_LINUX_SITE = \
+     $(call github,ffontaine,igd2-for-linux,$(IGD2_FOR_LINUX_VERSION))
+
+IGD2_FOR_LINUX_LICENSE = GPLv2
+IGD2_FOR_LINUX_LICENSE_FILES = linuxigd2/doc/LICENSE
+

package/igd2-for-linux/S99upnpd line 29

Quoted 10 lines
package/igd2-for-linux/S99upnpd new file +10 -0
+IGD2_FOR_LINUX_DEPENDENCIES = libupnp
+
+IGD2_FOR_LINUX_BUILD_DIR = $(@D)/linuxigd2
+IGD2_FOR_LINUX_CONF_DIR = $(IGD2_FOR_LINUX_BUILD_DIR)/configs
+
+define IGD2_FOR_LINUX_BUILD_CMDS
+     $(TARGET_MAKE_ENV) $(MAKE) -C $(IGD2_FOR_LINUX_BUILD_DIR) \
+     $(TARGET_CONFIGURE_OPTS) \
+     LIBUPNP_PREFIX="$(STAGING_DIR)/usr" \
+     all

Please indent the continuation lines:

        $(TARGET_MAKE_ENV) $(MAKE) -C $($(IGD2_FOR_LINUX_BUILD_DIR) \
                $(TARGET_CONFIGURE_OPTS) \
                ... \
                ...
Quoted 6 lines
package/igd2-for-linux/S99upnpd new file +6 -0
+endef
+
+define IGD2_FOR_LINUX_INSTALL_TARGET_CMDS
+     $(INSTALL) -D -m 0755 $(IGD2_FOR_LINUX_BUILD_DIR)/bin/upnpd \
+             $(TARGET_DIR)/usr/sbin/upnpd
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/ligd.png \

package/igd2-for-linux/S99upnpd

Quoted 10 lines
package/igd2-for-linux/S99upnpd new file +10 -0
+             $(TARGET_DIR)/etc/linuxigd/ligd.png
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/dummy.xml \
+             $(TARGET_DIR)/etc/linuxigd/dummy.xml
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gateconnSCPD.xml \
+             $(TARGET_DIR)/etc/linuxigd/gateconnSCPD.xml
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gatedesc1.xml \
+             $(TARGET_DIR)/etc/linuxigd/gatedesc1.xml
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gatedesc.xml \
+             $(TARGET_DIR)/etc/linuxigd/gatedesc.xml
+     $(INSTALL) -D -m 0644

$(IGD2_FOR_LINUX_CONF_DIR)/gateEthlcfgSCPD.xml \

package/igd2-for-linux/S99upnpd

Quoted 4 lines
package/igd2-for-linux/S99upnpd new file +4 -0
+             $(TARGET_DIR)/etc/linuxigd/gateEthlcfgSCPD.xml
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/gateicfgSCPD.xml \
+             $(TARGET_DIR)/etc/linuxigd/gateicfgSCPD.xml
+     $(INSTALL) -D -m 0644

$(IGD2_FOR_LINUX_CONF_DIR)/lanhostconfigSCPD.xml \

package/igd2-for-linux/S99upnpd

Quoted 2 lines
package/igd2-for-linux/S99upnpd new file +2 -0
+             $(TARGET_DIR)/etc/linuxigd/lanhostconfigSCPD.xml
+     $(INSTALL) -D -m 0644

$(IGD2_FOR_LINUX_CONF_DIR)/wanipv6fwctrlSCPD.xml \

package/igd2-for-linux/S99upnpd

Quoted 3 lines
package/igd2-for-linux/S99upnpd new file +3 -0
+             $(TARGET_DIR)/etc/linuxigd/wanipv6fwctrlSCPD.xml
+     $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/upnpd.conf \
+             $(TARGET_DIR)/etc/upnpd.conf

Can you write instead:

        $(INSTALL) -D -m 0755 $(IGD2_FOR_LINUX_BUILD_DIR)/bin/upnpd \
                $(TARGET_DIR)/usr/sbin/upnpd
        $(INSTALL) -D -m 0644 $(IGD2_FOR_LINUX_CONF_DIR)/upnpd.conf \
                $(TARGET_DIR)/etc/upnpd.conf
        mkdir -p $(TARGET_DIR)/etc/linuxigd/
        cp -dpfr $(IGD2_FOR_LINUX_CONF_DIR)/*.{xml,png} \
                $(TARGET_DIR)/etc/linuxigd/

or alternatively, if you really want to copy explicitly each file one by one to /etc/linuxigd, define a variable like IGD2_FOR_LINUX_ETC_LINUXIGD_FILES, that lists all the filenames, and then use a foreach loop.

package/igd2-for-linux/S99upnpd

Quoted 2 lines
package/igd2-for-linux/S99upnpd new file +2 -0
+define IGD2_FOR_LINUX_INSTALL_INIT_SYSTEMD
+     $(INSTALL) -D -m 0644 package/domoticz/upnpd.service \

Hum, really package/domoticz ?

package/igd2-for-linux/S99upnpd

Quoted 4 lines
package/igd2-for-linux/S99upnpd new file +4 -0
+             $(TARGET_DIR)/usr/lib/systemd/system/upnpd.service
+     mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+     ln -sf ../../../../usr/lib/systemd/system/upnpd.service \
+

$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/upnpd.service

Review

Quoted 4 lines
package/igd2-for-linux/S99upnpd new file +3 -0
+endef
+
+$(eval $(generic-package))
(quoted diff) +0 -0

b/package/igd2-for-linux/upnpd.service

Quoted 5 lines

new file mode 100644
index 0000000..479f5b2

package/igd2-for-linux/upnpd.service line 9

Quoted 9 lines
package/igd2-for-linux/upnpd.service new file +9 -0
@@ -0,0 +1,12 @@
+[Unit]
+Description=UPnP Internet Gateway Device version 2 daemon
+After=network.target
+
+[Service]
+ExecStartPre=/sbin/route add -net 239.0.0.0 netmask 255.0.0.0 eth0
+ExecStart=/usr/sbin/upnpd -f eth0 eth0
+Restart=always
+ExecStopPost=/sbin/route del -net 239.0.0.0 netmask 255.0.0.0 eth0

Same questions about the customization of eth0 and 239.0.0.0.

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160721/fc6386c2/attachment.html>