miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

upnpdiscover problem

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation
View previous topic :: View next topic  
Author Message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Wed Jul 18, 2018 6:48 am    Post subject: upnpdiscover problem Reply with quote

whenever I called upnpDiscover, it just returned nullptr, and error = 0.
I could send standard ssdp messages to 239.255.255.250:1900, but received nothing.
I have a router with upnp enabled, and this wireless router can be seen in the Network as upnp device, in win7.
I ran upnp_test, and the result is :
TEST 1 - Operating System Support - PASSED
TEST 2 - SSDP Service Running Check - PASSED
TEST 3 - SSDP Service Automatic Check - PASSED
TEST 4 - UPnPHost Service Running Check - PASSED
TEST 5 - UPnPHost Service Automatic Check - PASSED
TEST 6 - UPnP Framework Firewall Exception Check - FAILED
TEST 7 - Adapter #0 - 192.168.0.102 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
TEST 7 - Adapter #1 - 192.168.52.1 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
TEST 7 - Adapter #2 - 192.168.121.1 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
I ran wireshark, and found that the router(192.168.0.1) didn't send any messages to 239.255.255.250:1900.
could you please help me to find out what problems there are, thank you!
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Wed Jul 18, 2018 7:52 am    Post subject: update problems Reply with quote

whenever I called upnpDiscover, it just returned nullptr, and error = 0.
I could send standard ssdp messages to 239.255.255.250:1900, but received nothing.
I have a router with upnp enabled, and this wireless router can be seen in the Network as upnp device, in win7.
I ran upnp_test, and the result is :
TEST 1 - Operating System Support - PASSED
TEST 2 - SSDP Service Running Check - PASSED
TEST 3 - SSDP Service Automatic Check - PASSED
TEST 4 - UPnPHost Service Running Check - PASSED
TEST 5 - UPnPHost Service Automatic Check - PASSED
TEST 6 - UPnP Framework Firewall Exception Check - FAILED
TEST 7 - Adapter #0 - 192.168.0.102 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
TEST 7 - Adapter #1 - 192.168.52.1 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
TEST 7 - Adapter #2 - 192.168.121.1 - PASSED
TEST 8 - Get External IP Address (Result: 100.216.19.62) - PASSED
I ran wireshark, and found that the router(192.168.0.1) send messages to 239.255.255.250:1900, and not receive any responses.
So do I need to setup some server on 239.255.255.250:1900 to receive messages and respond? or the problem is on windows Firewall?
could you please help me to find out what problems there are, thank you!
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Wed Jul 18, 2018 8:24 am    Post subject: i compiled miniupnpc on mac Reply with quote

i compiled miniupnpc on mac, and
Code:
$ ./upnpc-static -v
upnpc : miniupnpc library test client, version 2.1.
 (c) 2005-2018 Thomas Bernard.
Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
for more information.
No IGD UPnP Device found on the network !


also
Code:
$ ./listdevices
searching all UPnP devices
no device found.


and i have a router with upnp enabled, on 192.168.0.1 as well.
how can i make this router work as upnp device for my mac or win7?
thank you!
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Wed Jul 18, 2018 8:42 am    Post subject: Reply with quote

or should i run some firewall configuration for UPnP clients on my mac,
like
$ ipset create upnp hash:ip,port timeout 3
$ iptables -A OUTPUT -d 239.255.255.250/32 -p udp -m udp --dport 1900 -j SET --add-set upnp src,src --exist
$ iptables -A INPUT -p udp -m set --match-set upnp dst,dst -j ACCEPT
$ iptables -A INPUT -d 239.255.255.250/32 -p udp -m udp --dport 1900 -j ACCEPT
but on mac,
Code:
$ ipset create upnp hash:ip,port timeout 3
-bash: ipset: command not found


so what should i do?
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Thu Jul 19, 2018 1:33 am    Post subject: more tryings Reply with quote

Dear Mr. Bernard,

Bonjour!

I have compiled your miniupnpc and run firewall configuration on Ubuntu 16.04 in VMWare Workstation.

The VMWare Workstation was installed the win7, which connecting to a wirelss router with upnp enabled, what was descriped in my previose replies.

The operations are:
Code:

$ sudo ipset create upnp hash:ip,port timeout 3
$ sudo iptables -A OUTPUT -d 239.255.255.250/32 -p udp -m udp --dport 1900 -j SET --add-set upnp src,src --exist
$ sudo iptables -A INPUT -p udp -m set --match-set upnp dst,dst -j ACCEPT
$ sudo iptables -A INPUT -d 239.255.255.250/32 -p udp -m udp --dport 1900 -j ACCEPT


and result is:
Code:

jason@ubuntu:~/test/miniupnpc$ ./listdevices
searching all UPnP devices
no device found.
jason@ubuntu:~/test/miniupnpc$ ./upnpc-static -v
upnpc : miniupnpc library test client, version 2.1.
 (c) 2005-2018 Thomas Bernard.
Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
for more information.
No IGD UPnP Device found on the network !


Maybe because the ubuntu is in Vmware, and doesn't connect to the wireless router so it doesn't work.

My question is:
How can I make miniupnpc or the upnp router work in the win7, or the mac, or the ubuntu in VMWare, all that were descriped in my previose posts?

Thank you!

Yours sincerely,

Jason
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Thu Jul 19, 2018 7:05 am    Post subject: improving Reply with quote

Dear Mr. Bernard,

Bonjour!

I found that you used MiniSSDPd in miniupnpc, so I made a try to run a nodejs ssdp server (https://github.com/diversario/node-ssdp) in win7, and run the code:
Code:

string findRootDevice = string() +
"M-SEARCH * HTTP/1.1\r\n" +
"HOST: 239.255.255.250:1900\r\n" +
"MAN:\"ssdp:discover\"\r\n" +
"MX:3\r\n" +
"ST:upnp:rootdevice\r\n\r\n";
 
sockaddr_in server ={0};
server.sin_family = AF_INET;
server.sin_port = htons(1900);
server.sin_addr.s_addr = inet_addr("239.255.255.250");
err = sendto(su, findRootDevice.data(), findRootDevice.size(), 0, (sockaddr*)&server, sizeof(server));
if (err == -1)
{
 qDebug() << "sendto fail!" << endl;
return false;
}
else
{
qDebug() << "sendto success!" << endl;
}

data.resize(1024);
int len = sizeof(server);
err = recvfrom(su, (char *)data.data(), data.size(), 0, (sockaddr*)&server, &len);
if (err == -1)
{
 qDebug() << "recvfrom fail!" << endl;
}
else
{
qDebug() << "recvfrom success!" << endl;
}


and success!

Now I can find upnp:rootdevice and IGD in win7.

However I still can't find IGD by your miniupnpc in the vmware ubuntu, even I made the ubuntu connect directly to the router (with upnp enabled) by using Bridge mode.

Thank you!

Yours sincerely,

Jason
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Fri Jul 20, 2018 2:03 am    Post subject: continue Reply with quote

in win 7, with a tenda f3 router with upnp enable, on 192.168.0.1.
I send the below to 192.168.0.1:1980:
Code:

GET /InternetGatewayDevice.xml HTTP/1.1
Host: 192.168.0.1:1980

and received:
Code:

HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 3039
Connection: close
Pragma: no-cache

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
   <specVersion>
      <major>1</major>
      <minor>0</minor>
   </specVersion>
   <device>
      <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
      <friendlyName>Wireless-N Broadband Router</friendlyName>
      <manufacturer>Tenda</manufacturer>
      <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
      <modelDescription>Wireless-N Broadband Router</modelDescription>
      <modelName>Wireless-N Router</modelName>
      <modelNumber>Wireless-N Router</modelNumber>
      <serialNumber>0000001</serialNumber>
      <modelURL>http://www.tenda.com.cn</modelURL>
      <UDN>uuid:1b39635f-2479-e329-d8bd-4efddf0fa451</UDN>
      <serviceList>
         <service>
            <serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
            <serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
            <SCPDURL>/x_layer3forwarding.xml</SCPDURL>
            <controlURL>/control?Layer3Forwarding</controlURL>
            <eventSubURL>/event?Layer3Forwarding</eventSubURL>
         </service>
      </serviceList>
      <deviceList>
         <device>
            <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
            <friendlyName>Wireless-N Broadband Router</friendlyName>
            <manufacturer>Tenda</manufacturer>
            <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
            <modelDescription>Wireless-N Broadband Router</modelDescription>
            <modelName>Wireless-N Router</modelName>
            <modelURL>http://www.tenda.com.cn</modelURL>
            <UDN>uuid:297ccbfc-9b92-84a7-bc7b-f0242d9c6132</UDN>
            <serviceList>
               <service>
                  <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
                  <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
                  <SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
                  <controlURL>/control?WANCommonInterfaceConfig</controlURL>
                  <eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
               </service>
            </serviceList>
            <deviceList>
               <device>
                  <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
                  <friendlyName>Wireless-N Broadband Router</friendlyName>
                  <manufacturer>Tenda</manufacturer>
                  <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
                  <modelDescription>Wireless-N Broadband Router</modelDescription>
                  <modelName>Wireless-N Router</modelName>
                  <modelURL>http://www.tenda.com.cn</modelURL>
                  <UDN>uuid:dd921110-2050-e176-ab30-314aaf15a208</UDN>
                  <serviceList>
                     <service>
                        <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
                        <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
                        <SCPDURL>/x_wanipconnection.xml</SCPDURL>
                        <controlURL>/control?WANIPConnection</controlURL>
                        <eventSubURL>/event?WANIPConnection</eventSubURL>
                     </service>
                  </serviceList>
               </device>
            </deviceList>
         </device>
      </deviceList>
      <presentationURL>http://192.168.0.1</presentationURL>
   </device>
</root>


Trying GetGenericPortMappingEntry, I send:
Code:

POST /control?WANIPConnection HTTP/1.1
HOST: 192.168.0.1:1980
CONTENT-TYPE: text/xml;charset="utf-8"
CONTENT-LENGTH: 398
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry"

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
            <NewPortMappingIndex>0</NewPortMappingIndex>
        </u:GetGenericPortMappingEntry>
    </s:Body>
</s:Envelope>

and received:
Code:

HTTP/1.1 500 Internal Server Error
Content-Length: 384
Content-Type: text/xml; charset="utf-8"
Date: Fri, 20 Jul 2018 09:25:31 GMT
EXT:
Server: POSIX, UPnP/1.0 UPnP Stack/1.11.0.0
Connection: close

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring>UPnPError</faultstring><detail><UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>713</errorCode><errorDescription></errorDescription></UPnPError></detail></s:Fault></s:Body></s:Envelope>


Maybe the problems are with the router?It didn't provide functions about GetGenericPortMappingEntry. Or did I do something wrong?
keep digging..
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Fri Jul 20, 2018 9:03 am    Post subject: Reply with quote

please contact your router vendor for support.

You should check using tcpdump/wireshark/etc.
that is does send multicast SSDP packets to announce itself regurarly on the network, and that it receive and respond to multicast SSDP M-SEARCH requests.

Error 713 is one normal response for GetGenericPortMappingEntry
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Sat Jul 21, 2018 6:17 am    Post subject: Thanks for reply! Reply with quote

Dear Mr. Bernard,

Bonjour!

Thank you so much for your attention and response!

With your project information and help, I am getting closer to the truth.

Now the situation is :
I am using a tenda f3 router with upnp enabled. It is working on 198.168.0.1:1980.
By sending ssdp request, I have got the controlUrl, AddPortMapping (between 192.168.0.102:25550(my win7) and external port 25550), GetGenericPortMappingEntry (show the above mapping), GetExternalIPAddress (got NewExternalIPAddress 100.208.131.37).

The IPAddress (100.208.131.37) is as same as the WAN IP of the router, but is not a public network IP.
Maybe I should ask my ISP to provide a public network IP for my router, then my pc can be visited from internet through the portmapping.

I have bought a Netgear WGT624 router, which is on delivering.
Netgear WGT624 is said 100%ok on the Compatibility list (https://miniupnp.tuxfamily.org/devicelist.php), so I thought It would work with miniupnpc, such as can be found by upnpc-static.exe -p.
and I thought it would meet the same problem that the WAN IP is not a public network IP.

Keep trying..

Thank you so much again!
Wish you good weekend!

Yours sincerely,
Jason
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Sat Jul 21, 2018 6:44 am    Post subject: Reply with quote

Code:

0.
upnpc to add/delete/show port mapping entry
http://www.it610.com/article/4554639.htm

1.
node-ssdp
https://github.com/diversario/node-ssdp
node example/server.js

advertise-alive { HOST: '239.255.255.250:1900',
  'CACHE-CONTROL': 'max-age=600',
  LOCATION: 'http://192.168.0.1:1980/InternetGatewayDevice.xml',
  NTS: 'ssdp:alive',
  SERVER: 'POSIX, UPnP/1.0 UPnP Stack/1.11.0.0',
  NT: 'urn:schemas-upnp-org:device:InternetGatewayDevice:1',
  USN: 'uuid:1b39635f-2479-e329-d8bd-4efddf0fa451::urn:schemas-upnp-org:device:InternetGatewayDevice:1' }

advertise-alive { HOST: '239.255.255.250:1900',
  'CACHE-CONTROL': 'max-age=600',
  LOCATION: 'http://192.168.0.1:1980/InternetGatewayDevice.xml',
  NTS: 'ssdp:alive',
  SERVER: 'POSIX, UPnP/1.0 UPnP Stack/1.11.0.0',
  NT: 'upnp:rootdevice',
  USN: 'uuid:1b39635f-2479-e329-d8bd-4efddf0fa451::upnp:rootdevice' }

advertise-alive { HOST: '239.255.255.250:1900',
  NT: 'upnp:rootdevice',
  NTS: 'ssdp:alive',
  USN: 'uuid:f40c2981-7329-40b7-8b04-27f187aecfb5::upnp:rootdevice',
  'CACHE-CONTROL': 'max-age=1800',
  SERVER: 'node.js/8.9.0 UPnP/1.1 node-ssdp/3.3.0',
  LOCATION: 'http://192.168.0.102:8080/ssdp/device-desc.xml' }

2.
SearchUpnpRootDevice:

right:
send: 
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST:urn:schemas-upnp-org:device:InternetGatewayDevice:1
MAN:"ssdp:discover"
MX:3

recvfrom fail

wrong:
send: 
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST:upnp:rootdevice
MAN:"ssdp:discover"
MX:3

recv: 
HTTP/1.1 200 OK
ST: upnp:rootdevice
USN: uuid:f40c2981-7329-40b7-8b04-27f187aecfb5::upnp:rootdevice
CACHE-CONTROL: max-age=1800
DATE: Sat, 21 Jul 2018 05:18:34 GMT
SERVER: node.js/8.9.0 UPnP/1.1 node-ssdp/3.3.0
EXT:
LOCATION: http://192.168.0.102:8080/ssdp/device-desc.xml

send: 
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST:ssdp:all
MAN:"ssdp:discover"
MX:3
 
recv: 
HTTP/1.1 200 OK
ST: urn:schemas-upnp-org:service:ConnectionManager:1
USN: uuid:f40c2981-7329-40b7-8b04-27f187aecfb5::urn:schemas-upnp-org:service:ConnectionManager:1
CACHE-CONTROL: max-age=1800
DATE: Sat, 21 Jul 2018 05:40:34 GMT
SERVER: node.js/8.9.0 UPnP/1.1 node-ssdp/3.3.0
EXT:
LOCATION: http://192.168.0.102:8080/ssdp/device-desc.xml

ST: upnp:rootdevice
ST: urn:schemas-upnp-org:device:MediaServer:1
ST: urn:schemas-upnp-org:service:ContentDirectory:1
etc
LOCATION: http://192.168.0.102:8080/ssdp/device-desc.xml

Maybe because node-ssdp is set on 192.168.0.102:8080, while I send requestes to 239.255.255.250:1900,
can only receive ssdp messages about devices and services on 192.168.0.102:8080.
But node-ssdp itseld can receive ssdp messages from upnp router (192.168.0.1:1980).
The miniupnpc has included MiniSSDPd, which can receive and send ssdp messages,
so maybe miniupnpc can received ssdp message from upnp router without external ssdp server?

3.
win7
tenda F3
192.168.0.1:1980

send:
GET /InternetGatewayDevice.xml HTTP/1.1
Host: 192.168.0.1:1980

recv:
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 3039
Connection: close
Pragma: no-cache

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
   <specVersion>
      <major>1</major>
      <minor>0</minor>
   </specVersion>
   <device>
      <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
      <friendlyName>Wireless-N Broadband Router</friendlyName>
      <manufacturer>Tenda</manufacturer>
      <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
      <modelDescription>Wireless-N Broadband Router</modelDescription>
      <modelName>Wireless-N Router</modelName>
      <modelNumber>Wireless-N Router</modelNumber>
      <serialNumber>0000001</serialNumber>
      <modelURL>http://www.tenda.com.cn</modelURL>
      <UDN>uuid:1b39635f-2479-e329-d8bd-4efddf0fa451</UDN>
      <serviceList>
         <service>
            <serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
            <serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
            <SCPDURL>/x_layer3forwarding.xml</SCPDURL>
            <controlURL>/control?Layer3Forwarding</controlURL>
            <eventSubURL>/event?Layer3Forwarding</eventSubURL>
         </service>
      </serviceList>
      <deviceList>
         <device>
            <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
            <friendlyName>Wireless-N Broadband Router</friendlyName>
            <manufacturer>Tenda</manufacturer>
            <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
            <modelDescription>Wireless-N Broadband Router</modelDescription>
            <modelName>Wireless-N Router</modelName>
            <modelURL>http://www.tenda.com.cn</modelURL>
            <UDN>uuid:297ccbfc-9b92-84a7-bc7b-f0242d9c6132</UDN>
            <serviceList>
               <service>
                  <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
                  <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
                  <SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
                  <controlURL>/control?WANCommonInterfaceConfig</controlURL>
                  <eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
               </service>
            </serviceList>
            <deviceList>
               <device>
                  <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
                  <friendlyName>Wireless-N Broadband Router</friendlyName>
                  <manufacturer>Tenda</manufacturer>
                  <manufacturerURL>http://www.tenda.com.cn</manufacturerURL>
                  <modelDescription>Wireless-N Broadband Router</modelDescription>
                  <modelName>Wireless-N Router</modelName>
                  <modelURL>http://www.tenda.com.cn</modelURL>
                  <UDN>uuid:dd921110-2050-e176-ab30-314aaf15a208</UDN>
                  <serviceList>
                     <service>
                        <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
                        <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
                        <SCPDURL>/x_wanipconnection.xml</SCPDURL>
                        <controlURL>/control?WANIPConnection</controlURL>
                        <eventSubURL>/event?WANIPConnection</eventSubURL>
                     </service>
                  </serviceList>
               </device>
            </deviceList>
         </device>
      </deviceList>
      <presentationURL>http://192.168.0.1</presentationURL>
   </device>
</root>

4.
AddPortMapping

send: 
POST /control?WANIPConnection HTTP/1.1
HOST: 192.168.0.1:1980
CONTENT-TYPE: text/xml;charset="utf-8"
CONTENT-LENGTH: 758
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
            <NewExternalPort>25550</NewExternalPort>
            <NewInternalPort>25550</NewInternalPort>
            <NewProtocol>TCP</NewProtocol>
            <NewInternalClient>192.168.0.102</NewInternalClient>
            <NewLeaseDuration></NewLeaseDuration>
            <NewPortMappingDescription>Mapping By UpnpPortMapping</NewPortMappingDescription>
            <NewRemoteHost></NewRemoteHost>
            <NewEnabled>1</NewEnabled>
        </u:AddPortMapping>
    </s:Body>
</s:Envelope>
 

recv: 
HTTP/1.1 200 OK
Content-Length: 276
Content-Type: text/xml; charset="utf-8"
Date: Sat, 21 Jul 2018 07:28:24 GMT
EXT:
Server: POSIX, UPnP/1.0 UPnP Stack/1.11.0.0
Connection: close

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
</u:AddPortMappingResponse>
</s:Body>
</s:Envelope>

5.
GetGenericPortMappingEntry

send: 
POST /control?WANIPConnection HTTP/1.1
HOST: 192.168.0.1:1980
CONTENT-TYPE: text/xml;charset="utf-8"
CONTENT-LENGTH: 398
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry"

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
            <NewPortMappingIndex>0</NewPortMappingIndex>
        </u:GetGenericPortMappingEntry>
    </s:Body>
</s:Envelope>


recv: 
HTTP/1.1 200 OK
Content-Length: 654
Content-Type: text/xml; charset="utf-8"
Date: Sat, 21 Jul 2018 07:32:35 GMT
EXT:
Server: POSIX, UPnP/1.0 UPnP Stack/1.11.0.0
Connection: close

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetGenericPortMappingEntryResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>25550</NewExternalPort>
<NewProtocol>TCP</NewProtocol>
<NewInternalPort>25550</NewInternalPort>
<NewInternalClient>192.168.0.102</NewInternalClient>
<NewEnabled>1</NewEnabled>
<NewPortMappingDescription>Mapping By UpnpPortMapping</NewPortMappingDescription>
<NewLeaseDuration>0</NewLeaseDuration>
</u:GetGenericPortMappingEntryResponse>
</s:Body>
</s:Envelope>

6.
GetExternalIPAddress

send: 
POST /control?WANIPConnection HTTP/1.1
HOST: 192.168.0.1:1980
CONTENT-TYPE: text/xml;charset="utf-8"
CONTENT-LENGTH: 296
SOAPACTION:"urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/>
    </s:Body>
</s:Envelope>
 
recv: 
HTTP/1.1 200 OK
Content-Length: 349
Content-Type: text/xml; charset="utf-8"
Date: Sat, 21 Jul 2018 08:53:02 GMT
EXT:
Server: POSIX, UPnP/1.0 UPnP Stack/1.11.0.0
Connection: close

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetExternalIPAddressResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewExternalIPAddress>100.208.131.37</NewExternalIPAddress>
</u:GetExternalIPAddressResponse>
</s:Body>
</s:Envelope>
Back to top
View user's profile Send private message
jason001



Joined: 18 Jul 2018
Posts: 16
Location: China

PostPosted: Mon Jul 23, 2018 2:11 pm    Post subject: Reply with quote

I have received the netgear wgt624 v3 router, and it work well with miniupnpc.
Now all I need is to change my ISP to who can provide public network IP.
Code:

1.
c:\upnpc>upnpc-static.exe -P
upnpc : miniupnpc library test client, version 1.9.
 (c) 2005-2014 Thomas Bernard.
Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
for more information.
List of UPNP devices found on the network :
 desc: http://192.168.0.1:80/Public_UPNP_gatedesc.xml
 st: urn:schemas-upnp-org:device:InternetGatewayDevice:1

Found valid IGD : http://192.168.0.1:80/Public_UPNP_C3
Local LAN ip address : 192.168.0.2
Presentation URL found:
            /start.htm
2.
linux
miniupnpc
jason@ubuntu:~/test/miniupnpc$ ./upnpc-static -P
upnpc : miniupnpc library test client, version 2.1.
 
(c) 2005-2018 Thomas Bernard.
Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
for more information.
List of UPNP devices found on the network :
desc: http://192.168.0.1:80/Public_UPNP_gatedesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1

Found a (not connected?) IGD : http://192.168.0.1:80/Public_UPNP_C3
Trying to continue anyway
Local LAN ip address : 192.168.0.3
Presentation URL found:         
/start.htm

3.
linux
devlist = upnpDiscover(10000, NULL, NULL, 0, 0, &error);
dev->descURL, dev->st
UPnP device :
 desc: http://192.168.0.1:80/Public_UPNP_gatedesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
i = UPNP_GetValidIGD(devlist, urls, data, (char*)&lanaddr, 16);
i =  1
m_lanip =  192.168.0.3


Thank you for your help!Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.