mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
add missing miniupnpc files, modify cmake to not build miniupnpc tests and to fix an issue with finding miniupnpcstrings
This commit is contained in:
parent
7da9905589
commit
bd8e0fd2a1
4
external/miniupnpc/CMakeLists.txt
vendored
4
external/miniupnpc/CMakeLists.txt
vendored
@ -18,7 +18,7 @@ endif()
|
||||
option (UPNPC_BUILD_STATIC "Build static library" TRUE)
|
||||
option (UPNPC_BUILD_SHARED "Build shared library" TRUE)
|
||||
if (NOT WIN32)
|
||||
option (UPNPC_BUILD_TESTS "Build test executables" TRUE)
|
||||
option (UPNPC_BUILD_TESTS "Build test executables" FALSE)
|
||||
endif (NOT WIN32)
|
||||
option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
|
||||
|
||||
@ -62,7 +62,7 @@ if (CMAKE_COMPILER_IS_GNUC)
|
||||
endif (NOT CONFIGURED)
|
||||
endif ()
|
||||
|
||||
configure_file (${CMAKE_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_BINARY_DIR}/miniupnpcstrings.h)
|
||||
configure_file (miniupnpcstrings.h.cmake ${CMAKE_BINARY_DIR}/miniupnpcstrings.h)
|
||||
include_directories (${CMAKE_BINARY_DIR})
|
||||
|
||||
set (MINIUPNPC_SOURCES
|
||||
|
110
external/miniupnpc/listdevices.c
vendored
Normal file
110
external/miniupnpc/listdevices.c
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/* $Id: listdevices.c,v 1.6 2015/07/23 20:40:08 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2013-2015 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#endif /* _WIN32 */
|
||||
#include "miniupnpc.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
const char * searched_device = NULL;
|
||||
const char * * searched_devices = NULL;
|
||||
const char * multicastif = 0;
|
||||
const char * minissdpdpath = 0;
|
||||
int ipv6 = 0;
|
||||
unsigned char ttl = 2;
|
||||
int error = 0;
|
||||
struct UPNPDev * devlist = 0;
|
||||
struct UPNPDev * dev;
|
||||
int i;
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||
if(nResult != NO_ERROR)
|
||||
{
|
||||
fprintf(stderr, "WSAStartup() failed.\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
for(i = 1; i < argc; i++) {
|
||||
if(strcmp(argv[i], "-6") == 0)
|
||||
ipv6 = 1;
|
||||
else if(strcmp(argv[i], "-d") == 0) {
|
||||
if(++i >= argc) {
|
||||
fprintf(stderr, "%s option needs one argument\n", "-d");
|
||||
return 1;
|
||||
}
|
||||
searched_device = argv[i];
|
||||
} else if(strcmp(argv[i], "-t") == 0) {
|
||||
if(++i >= argc) {
|
||||
fprintf(stderr, "%s option needs one argument\n", "-t");
|
||||
return 1;
|
||||
}
|
||||
ttl = (unsigned char)atoi(argv[i]);
|
||||
} else if(strcmp(argv[i], "-l") == 0) {
|
||||
if(++i >= argc) {
|
||||
fprintf(stderr, "-l option needs at least one argument\n");
|
||||
return 1;
|
||||
}
|
||||
searched_devices = (const char * *)(argv + i);
|
||||
break;
|
||||
} else if(strcmp(argv[i], "-m") == 0) {
|
||||
if(++i >= argc) {
|
||||
fprintf(stderr, "-m option needs one argument\n");
|
||||
return 1;
|
||||
}
|
||||
multicastif = argv[i];
|
||||
} else {
|
||||
printf("usage : %s [options] [-l <device1> <device2> ...]\n", argv[0]);
|
||||
printf("options :\n");
|
||||
printf(" -6 : use IPv6\n");
|
||||
printf(" -m address/ifname : network interface to use for multicast\n");
|
||||
printf(" -d <device string> : search only for this type of device\n");
|
||||
printf(" -l <device1> <device2> ... : search only for theses types of device\n");
|
||||
printf(" -t ttl : set multicast TTL. Default value is 2.\n");
|
||||
printf(" -h : this help\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(searched_device) {
|
||||
printf("searching UPnP device type %s\n", searched_device);
|
||||
devlist = upnpDiscoverDevice(searched_device,
|
||||
2000, multicastif, minissdpdpath,
|
||||
0/*localport*/, ipv6, ttl, &error);
|
||||
} else if(searched_devices) {
|
||||
printf("searching UPnP device types :\n");
|
||||
for(i = 0; searched_devices[i]; i++)
|
||||
printf("\t%s\n", searched_devices[i]);
|
||||
devlist = upnpDiscoverDevices(searched_devices,
|
||||
2000, multicastif, minissdpdpath,
|
||||
0/*localport*/, ipv6, ttl, &error, 1);
|
||||
} else {
|
||||
printf("searching all UPnP devices\n");
|
||||
devlist = upnpDiscoverAll(2000, multicastif, minissdpdpath,
|
||||
0/*localport*/, ipv6, ttl, &error);
|
||||
}
|
||||
if(devlist) {
|
||||
for(dev = devlist, i = 1; dev != NULL; dev = dev->pNext, i++) {
|
||||
printf("%3d: %-48s\n", i, dev->st);
|
||||
printf(" %s\n", dev->descURL);
|
||||
printf(" %s\n", dev->usn);
|
||||
}
|
||||
freeUPNPDevlist(devlist);
|
||||
} else {
|
||||
printf("no device found.\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
21
external/miniupnpc/miniupnpc_declspec.h
vendored
Normal file
21
external/miniupnpc/miniupnpc_declspec.h
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef MINIUPNPC_DECLSPEC_H_INCLUDED
|
||||
#define MINIUPNPC_DECLSPEC_H_INCLUDED
|
||||
|
||||
#if defined(_WIN32) && !defined(MINIUPNP_STATICLIB)
|
||||
/* for windows dll */
|
||||
#ifdef MINIUPNP_EXPORTS
|
||||
#define MINIUPNP_LIBSPEC __declspec(dllexport)
|
||||
#else
|
||||
#define MINIUPNP_LIBSPEC __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
/* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */
|
||||
#define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define MINIUPNP_LIBSPEC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* MINIUPNPC_DECLSPEC_H_INCLUDED */
|
||||
|
52
external/miniupnpc/pymoduletest3.py
vendored
Executable file
52
external/miniupnpc/pymoduletest3.py
vendored
Executable file
@ -0,0 +1,52 @@
|
||||
#! /usr/bin/python3
|
||||
# MiniUPnP project
|
||||
# Author : Thomas Bernard
|
||||
# This Sample code is public domain.
|
||||
# website : http://miniupnp.tuxfamily.org/
|
||||
|
||||
# import the python miniupnpc module
|
||||
import miniupnpc
|
||||
import sys
|
||||
|
||||
# create the object
|
||||
u = miniupnpc.UPnP()
|
||||
print('inital(default) values :')
|
||||
print(' discoverdelay', u.discoverdelay)
|
||||
print(' lanaddr', u.lanaddr)
|
||||
print(' multicastif', u.multicastif)
|
||||
print(' minissdpdsocket', u.minissdpdsocket)
|
||||
u.discoverdelay = 200;
|
||||
#u.minissdpdsocket = '../minissdpd/minissdpd.sock'
|
||||
# discovery process, it usualy takes several seconds (2 seconds or more)
|
||||
print('Discovering... delay=%ums' % u.discoverdelay)
|
||||
print(u.discover(), 'device(s) detected')
|
||||
# select an igd
|
||||
try:
|
||||
u.selectigd()
|
||||
except Exception as e:
|
||||
print('Exception :', e)
|
||||
sys.exit(1)
|
||||
# display information about the IGD and the internet connection
|
||||
print('local ip address :', u.lanaddr)
|
||||
print('external ip address :', u.externalipaddress())
|
||||
print(u.statusinfo(), u.connectiontype())
|
||||
|
||||
#print u.addportmapping(64000, 'TCP',
|
||||
# '192.168.1.166', 63000, 'port mapping test', '')
|
||||
#print u.deleteportmapping(64000, 'TCP')
|
||||
|
||||
port = 0
|
||||
proto = 'UDP'
|
||||
# list the redirections :
|
||||
i = 0
|
||||
while True:
|
||||
p = u.getgenericportmapping(i)
|
||||
if p==None:
|
||||
break
|
||||
print(i, p)
|
||||
(port, proto, (ihost,iport), desc, c, d, e) = p
|
||||
#print port, desc
|
||||
i = i + 1
|
||||
|
||||
print(u.getspecificportmapping(port, proto))
|
||||
|
14
external/miniupnpc/testdesc/linksys_WAG200G_desc.values
vendored
Normal file
14
external/miniupnpc/testdesc/linksys_WAG200G_desc.values
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# values for linksys_WAG200G_desc.xml
|
||||
|
||||
CIF:
|
||||
servicetype = urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
|
||||
controlurl = /upnp/control/WANCommonIFC1
|
||||
eventsuburl = /upnp/event/WANCommonIFC1
|
||||
scpdurl = /cmnicfg.xml
|
||||
|
||||
first:
|
||||
servicetype = urn:schemas-upnp-org:service:WANPPPConnection:1
|
||||
controlurl = /upnp/control/WANPPPConn1
|
||||
eventsuburl = /upnp/event/WANPPPConn1
|
||||
scpdurl = /pppcfg.xml
|
||||
|
110
external/miniupnpc/testdesc/linksys_WAG200G_desc.xml
vendored
Normal file
110
external/miniupnpc/testdesc/linksys_WAG200G_desc.xml
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0"?>
|
||||
<root xmlns="urn:schemas-upnp-org:device-1-0">
|
||||
<specVersion>
|
||||
<major>1</major>
|
||||
<minor>0</minor>
|
||||
</specVersion>
|
||||
<URLBase>http://192.168.1.1:49152</URLBase>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
|
||||
<friendlyName>LINKSYS WAG200G Gateway</friendlyName>
|
||||
<manufacturer>LINKSYS</manufacturer>
|
||||
<manufacturerURL>http://www.linksys.com</manufacturerURL>
|
||||
<modelDescription>LINKSYS WAG200G Gateway</modelDescription>
|
||||
<modelName>Wireless-G ADSL Home Gateway</modelName>
|
||||
<modelNumber>WAG200G</modelNumber>
|
||||
<modelURL>http://www.linksys.com</modelURL>
|
||||
<serialNumber>123456789</serialNumber>
|
||||
<UDN>uuid:8ca2eb37-1dd2-11b2-86f1-001a709b5aa8</UDN>
|
||||
<UPC>WAG200G</UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
|
||||
<controlURL>/upnp/control/L3Forwarding1</controlURL>
|
||||
<eventSubURL>/upnp/event/L3Forwarding1</eventSubURL>
|
||||
<SCPDURL>/l3frwd.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
<deviceList>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
|
||||
<friendlyName>WANDevice</friendlyName>
|
||||
<manufacturer>LINKSYS</manufacturer>
|
||||
<manufacturerURL>http://www.linksys.com/</manufacturerURL>
|
||||
<modelDescription>Residential Gateway</modelDescription>
|
||||
<modelName>Internet Connection Sharing</modelName>
|
||||
<modelNumber>1</modelNumber>
|
||||
<modelURL>http://www.linksys.com/</modelURL>
|
||||
<serialNumber>0000001</serialNumber>
|
||||
<UDN>uuid:8ca2eb36-1dd2-11b2-86f1-001a709b5aa8</UDN>
|
||||
<UPC>WAG200G</UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
|
||||
<controlURL>/upnp/control/WANCommonIFC1</controlURL>
|
||||
<eventSubURL>/upnp/event/WANCommonIFC1</eventSubURL>
|
||||
<SCPDURL>/cmnicfg.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
<deviceList>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
|
||||
<friendlyName>WANConnectionDevice</friendlyName>
|
||||
<manufacturer>LINKSYS</manufacturer>
|
||||
<manufacturerURL>http://www.linksys.com/</manufacturerURL>
|
||||
<modelDescription>Residential Gateway</modelDescription>
|
||||
<modelName>Internet Connection Sharing</modelName>
|
||||
<modelNumber>1</modelNumber>
|
||||
<modelURL>http://www.linksys.com/</modelURL>
|
||||
<serialNumber>0000001</serialNumber>
|
||||
<UDN>uuid:8ca2eb37-1dd2-11b2-86f0-001a709b5aa8</UDN>
|
||||
<UPC>WAG200G</UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANEthernetLinkConfig:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANEthLinkC1</serviceId>
|
||||
<controlURL>/upnp/control/WANEthLinkC1</controlURL>
|
||||
<eventSubURL>/upnp/event/WANEthLinkC1</eventSubURL>
|
||||
<SCPDURL>/wanelcfg.xml</SCPDURL>
|
||||
</service>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANPPPConnection:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANPPPConn1</serviceId>
|
||||
<controlURL>/upnp/control/WANPPPConn1</controlURL>
|
||||
<eventSubURL>/upnp/event/WANPPPConn1</eventSubURL>
|
||||
<SCPDURL>/pppcfg.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
</device>
|
||||
</deviceList>
|
||||
</device>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:LANDevice:1</deviceType>
|
||||
<friendlyName>LANDevice</friendlyName>
|
||||
<manufacturer>LINKSYS</manufacturer>
|
||||
<manufacturerURL>http://www.linksys.com/</manufacturerURL>
|
||||
<modelDescription>Residential Gateway</modelDescription>
|
||||
<modelName>Residential Gateway</modelName>
|
||||
<modelNumber>1</modelNumber>
|
||||
<modelURL>http://www.linksys.com/</modelURL>
|
||||
<serialNumber>0000001</serialNumber>
|
||||
<UDN>uuid:8ca2eb36-1dd2-11b2-86f0-001a709b5aa
|
||||
8</UDN>
|
||||
<UPC>WAG200G</UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:LANHostConfigManagement:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:LANHostCfg1</serviceId>
|
||||
<controlURL>/upnp/control/LANHostCfg1</controlURL>
|
||||
<eventSubURL>/upnp/event/LANHostCfg1</eventSubURL>
|
||||
<SCPDURL>/lanhostc.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
</device>
|
||||
</deviceList>
|
||||
<presentationURL>http://192.168.1.1/index.htm</presentationURL>
|
||||
</device>
|
||||
</root>
|
||||
|
20
external/miniupnpc/testdesc/new_LiveBox_desc.values
vendored
Normal file
20
external/miniupnpc/testdesc/new_LiveBox_desc.values
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# values for new_LiveBox_desc.xml
|
||||
|
||||
CIF:
|
||||
servicetype = urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
|
||||
controlurl = /87895a19/upnp/control/WANCommonIFC1
|
||||
eventsuburl = /87895a19/upnp/control/WANCommonIFC1
|
||||
scpdurl = /87895a19/gateicfgSCPD.xml
|
||||
|
||||
first:
|
||||
servicetype = urn:schemas-upnp-org:service:WANPPPConnection:2
|
||||
controlurl = /87895a19/upnp/control/WANIPConn1
|
||||
eventsuburl = /87895a19/upnp/control/WANIPConn1
|
||||
scpdurl = /87895a19/gateconnSCPD_PPP.xml
|
||||
|
||||
IPv6FC:
|
||||
servicetype = urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
|
||||
controlurl = /87895a19/upnp/control/WANIPv6FwCtrl1
|
||||
eventsuburl = /87895a19/upnp/control/WANIPv6FwCtrl1
|
||||
scpdurl = /87895a19/wanipv6fwctrlSCPD.xml
|
||||
|
90
external/miniupnpc/testdesc/new_LiveBox_desc.xml
vendored
Normal file
90
external/miniupnpc/testdesc/new_LiveBox_desc.xml
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
<root xmlns="urn:schemas-upnp-org:device-1-0">
|
||||
<specVersion>
|
||||
<major>1</major>
|
||||
<minor>0</minor>
|
||||
</specVersion>
|
||||
<device>
|
||||
<pnpx:X_hardwareId xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11">VEN_0129&DEV_0000&SUBSYS_03&REV_250417</pnpx:X_hardwareId>
|
||||
<pnpx:X_compatibleId xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11">GenericUmPass</pnpx:X_compatibleId>
|
||||
<pnpx:X_deviceCategory xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11">NetworkInfrastructure.Gateway</pnpx:X_deviceCategory>
|
||||
<df:X_deviceCategory xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation">Network.Gateway</df:X_deviceCategory>
|
||||
<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:2</deviceType>
|
||||
<friendlyName>Orange Livebox</friendlyName>
|
||||
<manufacturer>Sagemcom</manufacturer>
|
||||
<manufacturerURL>http://www.sagemcom.com/</manufacturerURL>
|
||||
<modelName>Residential Livebox,(DSL,WAN Ethernet)</modelName>
|
||||
<UDN>uuid:87895a19-50f9-3736-a87f-115c230155f8</UDN>
|
||||
<modelDescription>Sagemcom,fr,SG30_sip-fr-4.28.35.1</modelDescription>
|
||||
<modelNumber>3</modelNumber>
|
||||
<serialNumber>LK14129DP441489</serialNumber>
|
||||
<presentationURL>http://192.168.1.1</presentationURL>
|
||||
<UPC></UPC>
|
||||
<iconList>
|
||||
<icon>
|
||||
<mimetype>image/png</mimetype>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
<depth>8</depth>
|
||||
<url>/87895a19/ligd.png</url>
|
||||
</icon>
|
||||
</iconList>
|
||||
<deviceList>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:WANDevice:2</deviceType>
|
||||
<friendlyName>WANDevice</friendlyName>
|
||||
<manufacturer>Sagemcom</manufacturer>
|
||||
<manufacturerURL>http://www.sagemcom.com/</manufacturerURL>
|
||||
<modelDescription>WAN Device on Sagemcom,fr,SG30_sip-fr-4.28.35.1</modelDescription>
|
||||
<modelName>Residential Livebox,(DSL,WAN Ethernet)</modelName>
|
||||
<modelNumber>3</modelNumber>
|
||||
<modelURL>http://www.sagemcom.com/</modelURL>
|
||||
<serialNumber>LK14129DP441489</serialNumber>
|
||||
<presentationURL>http://192.168.1.1</presentationURL>
|
||||
<UDN>uuid:e2397374-53d8-3fc6-8306-593ba1a34625</UDN>
|
||||
<UPC></UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
|
||||
<controlURL>/87895a19/upnp/control/WANCommonIFC1</controlURL>
|
||||
<eventSubURL>/87895a19/upnp/control/WANCommonIFC1</eventSubURL>
|
||||
<SCPDURL>/87895a19/gateicfgSCPD.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
<deviceList>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:2</deviceType>
|
||||
<friendlyName>WANConnectionDevice</friendlyName>
|
||||
<manufacturer>Sagemcom</manufacturer>
|
||||
<manufacturerURL>http://www.sagemcom.com/</manufacturerURL>
|
||||
<modelDescription>WanConnectionDevice on Sagemcom,fr,SG30_sip-fr-4.28.35.1</modelDescription>
|
||||
<modelName>Residential Livebox,(DSL,WAN Ethernet)</modelName>
|
||||
<modelNumber>3</modelNumber>
|
||||
<modelURL>http://www.sagemcom.com/</modelURL>
|
||||
<serialNumber>LK14129DP441489</serialNumber>
|
||||
<presentationURL>http://192.168.1.1</presentationURL>
|
||||
<UDN>uuid:44598a08-288e-32c9-8a4d-d3c008ede331</UDN>
|
||||
<UPC></UPC>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANPPPConnection:2</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
|
||||
<controlURL>/87895a19/upnp/control/WANIPConn1</controlURL>
|
||||
<eventSubURL>/87895a19/upnp/control/WANIPConn1</eventSubURL>
|
||||
<SCPDURL>/87895a19/gateconnSCPD_PPP.xml</SCPDURL>
|
||||
</service>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:WANIPv6FirewallControl:1</serviceType>
|
||||
<serviceId>urn:upnp-org:serviceId:WANIPv6FwCtrl1</serviceId>
|
||||
<controlURL>/87895a19/upnp/control/WANIPv6FwCtrl1</controlURL>
|
||||
<eventSubURL>/87895a19/upnp/control/WANIPv6FwCtrl1</eventSubURL>
|
||||
<SCPDURL>/87895a19/wanipv6fwctrlSCPD.xml</SCPDURL>
|
||||
</service>
|
||||
</serviceList>
|
||||
</device>
|
||||
</deviceList>
|
||||
</device>
|
||||
</deviceList>
|
||||
</device>
|
||||
</root>
|
151
external/miniupnpc/testportlistingparse.c
vendored
Normal file
151
external/miniupnpc/testportlistingparse.c
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
/* $Id: testportlistingparse.c,v 1.2 2014/11/01 10:37:32 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution.
|
||||
* */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "portlistingparse.h"
|
||||
|
||||
struct port_mapping {
|
||||
unsigned int leasetime;
|
||||
unsigned short externalport;
|
||||
unsigned short internalport;
|
||||
const char * remotehost;
|
||||
const char * client;
|
||||
const char * proto;
|
||||
const char * desc;
|
||||
unsigned char enabled;
|
||||
};
|
||||
|
||||
/* return the number of differences */
|
||||
int test(const char * portListingXml, int portListingXmlLen,
|
||||
const struct port_mapping * ref, int count)
|
||||
{
|
||||
int i;
|
||||
int r = 0;
|
||||
struct PortMappingParserData data;
|
||||
struct PortMapping * pm;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
ParsePortListing(portListingXml, portListingXmlLen, &data);
|
||||
for(i = 0, pm = data.l_head;
|
||||
(pm != NULL) && (i < count);
|
||||
i++, pm = pm->l_next) {
|
||||
printf("%2d %s %5hu->%s:%-5hu '%s' '%s' %u\n",
|
||||
i, pm->protocol, pm->externalPort, pm->internalClient,
|
||||
pm->internalPort,
|
||||
pm->description, pm->remoteHost,
|
||||
(unsigned)pm->leaseTime);
|
||||
if(0 != strcmp(pm->protocol, ref[i].proto)) {
|
||||
printf("protocol : '%s' != '%s'\n", pm->protocol, ref[i].proto);
|
||||
r++;
|
||||
}
|
||||
if(pm->externalPort != ref[i].externalport) {
|
||||
printf("externalPort : %hu != %hu\n",
|
||||
pm->externalPort, ref[i].externalport);
|
||||
r++;
|
||||
}
|
||||
if(0 != strcmp(pm->internalClient, ref[i].client)) {
|
||||
printf("client : '%s' != '%s'\n",
|
||||
pm->internalClient, ref[i].client);
|
||||
r++;
|
||||
}
|
||||
if(pm->internalPort != ref[i].internalport) {
|
||||
printf("internalPort : %hu != %hu\n",
|
||||
pm->internalPort, ref[i].internalport);
|
||||
r++;
|
||||
}
|
||||
if(0 != strcmp(pm->description, ref[i].desc)) {
|
||||
printf("description : '%s' != '%s'\n",
|
||||
pm->description, ref[i].desc);
|
||||
r++;
|
||||
}
|
||||
if(0 != strcmp(pm->remoteHost, ref[i].remotehost)) {
|
||||
printf("remoteHost : '%s' != '%s'\n",
|
||||
pm->remoteHost, ref[i].remotehost);
|
||||
r++;
|
||||
}
|
||||
if((unsigned)pm->leaseTime != ref[i].leasetime) {
|
||||
printf("leaseTime : %u != %u\n",
|
||||
(unsigned)pm->leaseTime, ref[i].leasetime);
|
||||
r++;
|
||||
}
|
||||
if(pm->enabled != ref[i].enabled) {
|
||||
printf("enabled : %d != %d\n",
|
||||
(int)pm->enabled, (int)ref[i].enabled);
|
||||
r++;
|
||||
}
|
||||
}
|
||||
if((i != count) || (pm != NULL)) {
|
||||
printf("count mismatch : i=%d count=%d pm=%p\n", i, count, pm);
|
||||
r++;
|
||||
}
|
||||
FreePortListing(&data);
|
||||
return r;
|
||||
}
|
||||
|
||||
const char test_document[] =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<p:PortMappingList xmlns:p=\"urn:schemas-upnp-org:gw:WANIPConnection\"\n"
|
||||
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
|
||||
"xsi:schemaLocation=\"urn:schemas-upnp-org:gw:WANIPConnection "
|
||||
"http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd\">\n"
|
||||
" <p:PortMappingEntry>\n"
|
||||
" <p:NewRemoteHost></p:NewRemoteHost>\n"
|
||||
" <p:NewExternalPort>5002</p:NewExternalPort>\n"
|
||||
" <p:NewProtocol>UDP</p:NewProtocol>\n"
|
||||
" <p:NewInternalPort>4001</p:NewInternalPort>\n"
|
||||
" <p:NewInternalClient>192.168.1.123</p:NewInternalClient>\n"
|
||||
" <p:NewEnabled>1</p:NewEnabled>\n"
|
||||
" <p:NewDescription>xxx</p:NewDescription>\n"
|
||||
" <p:NewLeaseTime>0</p:NewLeaseTime>\n"
|
||||
" </p:PortMappingEntry>\n"
|
||||
" <p:PortMappingEntry>\n"
|
||||
" <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost>\n"
|
||||
" <p:NewExternalPort>2345</p:NewExternalPort>\n"
|
||||
" <p:NewProtocol>TCP</p:NewProtocol>\n"
|
||||
" <p:NewInternalPort>2349</p:NewInternalPort>\n"
|
||||
" <p:NewInternalClient>192.168.1.137</p:NewInternalClient>\n"
|
||||
" <p:NewEnabled>1</p:NewEnabled>\n"
|
||||
" <p:NewDescription>dooom</p:NewDescription>\n"
|
||||
" <p:NewLeaseTime>346</p:NewLeaseTime>\n"
|
||||
" </p:PortMappingEntry>\n"
|
||||
" <p:PortMappingEntry>\n"
|
||||
" <p:NewRemoteHost>134.231.2.11</p:NewRemoteHost>\n"
|
||||
" <p:NewExternalPort>12345</p:NewExternalPort>\n"
|
||||
" <p:NewProtocol>TCP</p:NewProtocol>\n"
|
||||
" <p:NewInternalPort>12345</p:NewInternalPort>\n"
|
||||
" <p:NewInternalClient>192.168.1.137</p:NewInternalClient>\n"
|
||||
" <p:NewEnabled>1</p:NewEnabled>\n"
|
||||
" <p:NewDescription>dooom A</p:NewDescription>\n"
|
||||
" <p:NewLeaseTime>347</p:NewLeaseTime>\n"
|
||||
" </p:PortMappingEntry>\n"
|
||||
"</p:PortMappingList>";
|
||||
|
||||
#define PORT_MAPPINGS_COUNT 3
|
||||
const struct port_mapping port_mappings[PORT_MAPPINGS_COUNT] = {
|
||||
{347, 12345, 12345, "134.231.2.11", "192.168.1.137", "TCP", "dooom A", 1},
|
||||
{346, 2345, 2349, "202.233.2.1", "192.168.1.137", "TCP", "dooom", 1},
|
||||
{0, 5002, 4001, "", "192.168.1.123", "UDP", "xxx", 1}
|
||||
};
|
||||
|
||||
/* --- main --- */
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
r = test(test_document, sizeof(test_document) - 1,
|
||||
port_mappings, PORT_MAPPINGS_COUNT);
|
||||
if(r == 0) {
|
||||
printf("test of portlistingparse OK\n");
|
||||
return 0;
|
||||
} else {
|
||||
printf("test FAILED (%d differences counted)\n", r);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
23
external/miniupnpc/upnpdev.c
vendored
Normal file
23
external/miniupnpc/upnpdev.c
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/* $Id: upnpdev.c,v 1.1 2015/08/28 12:14:19 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Web : http://miniupnp.free.fr/
|
||||
* Author : Thomas BERNARD
|
||||
* copyright (c) 2005-2015 Thomas Bernard
|
||||
* This software is subjet to the conditions detailed in the
|
||||
* provided LICENSE file. */
|
||||
#include <stdlib.h>
|
||||
#include "upnpdev.h"
|
||||
|
||||
/* freeUPNPDevlist() should be used to
|
||||
* free the chained list returned by upnpDiscover() */
|
||||
void freeUPNPDevlist(struct UPNPDev * devlist)
|
||||
{
|
||||
struct UPNPDev * next;
|
||||
while(devlist)
|
||||
{
|
||||
next = devlist->pNext;
|
||||
free(devlist);
|
||||
devlist = next;
|
||||
}
|
||||
}
|
||||
|
36
external/miniupnpc/upnpdev.h
vendored
Normal file
36
external/miniupnpc/upnpdev.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* $Id: upnpdev.h,v 1.1 2015/08/28 12:14:19 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Web : http://miniupnp.free.fr/
|
||||
* Author : Thomas BERNARD
|
||||
* copyright (c) 2005-2015 Thomas Bernard
|
||||
* This software is subjet to the conditions detailed in the
|
||||
* provided LICENSE file. */
|
||||
#ifndef UPNPDEV_H_INCLUDED
|
||||
#define UPNPDEV_H_INCLUDED
|
||||
|
||||
#include "miniupnpc_declspec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct UPNPDev {
|
||||
struct UPNPDev * pNext;
|
||||
char * descURL;
|
||||
char * st;
|
||||
unsigned int scope_id;
|
||||
char * usn;
|
||||
char buffer[3];
|
||||
};
|
||||
|
||||
/* freeUPNPDevlist()
|
||||
* free list returned by upnpDiscover() */
|
||||
MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* UPNPDEV_H_INCLUDED */
|
Loading…
Reference in New Issue
Block a user