2014/07/19

[miniupnpd] miniupnpd 的 uPnP daemon使用

除了上一篇的uPnP client之外,更常使用的應該是uPnP的daemon,讓每個電腦和嵌入式裝置可以發出SSDP的Notify和M-Search Reply來確認目前聯結的網路裝置有哪些,以及具備哪些功能。



下載miniupnpd-1.8.tar.gz到Linux環境下

解壓縮
tar -vxf miniupnpd-1.8.tar.gz



然後輸入指令
make -f Makefile.linux

就可以編譯miniupnpd,編譯成功後會得到miniupnpd的執行檔

然後編輯在資料夾下的config檔案,把listening_ip更改成要廣播SSDP的interface,以eth1為例子
# LAN network interfaces IPs / networks
# there can be multiple listening ips for SSDP traffic.
# should be under the form nnn.nnn.nnn.nnn/nn
# It can also be the network interface name (ie "eth0")
# It if mandatory to use the network interface name to enable IPv6
# HTTP is available on all interfaces.
# When MULTIPLE_EXTERNAL_IP is enabled, the external ip
# address associated with the subnet follows. for example :
# listening_ip=192.168.0.1/24 88.22.44.13
#listening_ip=192.168.0.1/24
#listening_ip=192.168.10.109/24
listening_ip=eth1
# port for HTTP (descriptions and SOAP) traffic. set 0 for autoselect.
port=0
然後輸入
./miniupnpd -f miniupnpd.conf -i eth1 -d

執行miniupnp daemon

然後就可以看到裝置被M-Search Reply的結果

其中的Location即是Linux裝置的位置和XML device description的位置,在瀏覽器輸入
http://192.168.56.77:34832/rootDesc.xml

可以看到裝置的詳細資訊,利用Wire Shark攔截SSDP Notify封包內容

還有別的裝置發出的M-Search和Linux裝置回覆的M-Search reply


利用miniupnpd可以快速地在電腦和嵌入式裝置上實作出uPnP的協定。

沒有留言:

張貼留言