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 

Cant poll for WAN IP. Tips?

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> NAT/UPnP
View previous topic :: View next topic  
Author Message
suslik



Joined: 26 Apr 2007
Posts: 5
Location: Los Angeles

PostPosted: Thu Apr 26, 2007 1:05 am    Post subject: Cant poll for WAN IP. Tips? Reply with quote

Hi there.

Trying to see if I can use miniupnp for a small project of mine (http://accentsolution.com/socproject/). One of the things I would expect UPNP to do is let me know what the WAN address is.

Tried both, the -l and -s switches, and didn't see a single mentioning of my outside IP there.

Am I missing something? Any hints what I can do to squeeze WAN IP number out of UPNP? Judging by the status output, does it look like some functionality is missing on my router.

Bellow is some of the status output from my Linksys BEFSR81

Thx for any tips.

dd@laptop:~/projects/miniupnpc-1.0-RC4> ./upnpc -s
upnpc : miniupnp test client. (c) 2006 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.1.1:5678/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1

address miniwget : 192.168.1.102
2986 bytes read
urlbase = http://192.168.1.1:5678
WAN Device (Common interface config) :
deviceType = urn:schemas-upnp-org:device:WANDevice:1
serviceType = urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
controlURL = http://192.168.1.1:6688/WANCommonInterfaceConfig
eventSubURL = /WANCommonInterfaceConfig
SCPDURL = /WANCfg.xml
WAN Connection Device :
deviceType = urn:schemas-upnp-org:device:WANConnectionDevice:1
servicetype = urn:schemas-upnp-org:service:WANIPConnection:1
controlURL = http://192.168.1.1:2468//WANIPConnection
eventSubURL = /WANIPConnection
SCPDURL = /WANIPCn.xml
urls->ipcondescURL='http://192.168.1.1:5678/WANIPCn.xml' 35 n1=36
urls->controlURL='http://192.168.1.1:2468//WANIPConnection' 40 n2=64
urls->controlURL_CIF='http://192.168.1.1:6688/WANCommonInterfaceConfig' 48 n3=72
n=164 bufsize=164 ContLen=651 HeadLen=164
n=651 bufsize=815 ContLen=651 HeadLen=164
UPNPIGD_IsConnected(http://192.168.1.1:2468//WANIPConnection) = 1
n=164 bufsize=164 ContLen=651 HeadLen=164
n=651 bufsize=815 ContLen=651 HeadLen=164
Found valid IGD : http://192.168.1.1:2468//WANIPConnection
Local LAN ip address : 192.168.1.102
n=164 bufsize=164 ContLen=583 HeadLen=164
n=583 bufsize=747 ContLen=583 HeadLen=164
Connection Type : IP_Routed
Status : , uptime=68365
n=998 bufsize=998 ContLen=834 HeadLen=164
MaxBitRateDown : 100000000 bps MaxBitRateUp 100000000 bps
n=609 bufsize=609 ContLen=445 HeadLen=164
n=164 bufsize=164 ContLen=461 HeadLen=164
n=461 bufsize=625 ContLen=461 HeadLen=164
n=164 bufsize=164 ContLen=458 HeadLen=164
n=458 bufsize=622 ContLen=458 HeadLen=164
Bytes: Sent: 1 Recv: 2
Packets: Sent: 452238 Recv: 0
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Thu Apr 26, 2007 6:58 pm    Post subject: Reply with quote

indeed, neither -l or -s commands of the "upnpc" sample program display
the expernal IP address.
You can call the UPNP_GetExternalIPAddress() function to get it.
Back to top
View user's profile Send private message Visit poster's website
suslik



Joined: 26 Apr 2007
Posts: 5
Location: Los Angeles

PostPosted: Fri Apr 27, 2007 12:51 am    Post subject: Reply with quote

miniupnp wrote:
indeed, neither -l or -s commands of the "upnpc" sample program display
the expernal IP address.
You can call the UPNP_GetExternalIPAddress() function to get it.


Considered for a second way of adding output to your present upnp util to output externalIP, so I could later grep it...
Just looked at the code and immediately recalled why I ran away from C in the first place Smile Compared to Python, it's just painful to read for me.

In the end, mostly for just one reason, decided to implement the absolute minimum in python. The reason is simple - this is a desktop widget and re/pre-compiling is a no-no. Seems despite my really wanting to use miniupnp, I will have to "duplicate" it. Ugh...

I am following this simple UPNP IGD client implementation guide: http://zbowling.com/projects/upnp/

Since you already went through majority of the issues, I wonder if you have some tips for things the blog missed.

Thx.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Fri Apr 27, 2007 6:31 pm    Post subject: Reply with quote

implementing some UPNP IGD commands is Easy.
Being compatible with most routers and their bugs Sad is a bit harder.
You gave me the idea to add a Python API to libminiupnpc Smile
That won't help you much as it will still require to compile.
Back to top
View user's profile Send private message Visit poster's website
suslik



Joined: 26 Apr 2007
Posts: 5
Location: Los Angeles

PostPosted: Sat Apr 28, 2007 1:14 am    Post subject: Reply with quote

miniupnp wrote:
implementing some UPNP IGD commands is Easy.
Being compatible with most routers and their bugs Sad is a bit harder.


yeah, that scares me a lot as well.

miniupnp wrote:
You gave me the idea to add a Python API to libminiupnpc Smile
That won't help you much as it will still require to compile.


Well, not entirely true. Smile I would rather make the users compile miniupnp as part of install than duplicate your work all over.

What would actually help me is ExternalIP as part of -s output or some similar simple way to get it on command line. I would just grep it and be eternally happy that I don't have to implement it Smile

We could even push miniupnp further into limelight; it is rather hard to find this gem behind the noise of Intel's stack usage.

Unrelated:
One interesting thing I noticed while polling my upnp devices from python yesterday. I recv() all responses, and on my network, there are 2: Linksys router and a Liinux-based wireless AP (upnp tag is "media server", passthrough, no NAT/masking).
If I poll with upnpc -s or -l, I see only Wireless AP (if I turn off Linksys's upnp) and only Linsys if its upnp is on.
Is one-device-only behavior just because upnpc is a simple example?
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Mon Apr 30, 2007 2:03 pm    Post subject: Reply with quote

suslik wrote:

What would actually help me is ExternalIP as part of -s output or some similar simple way to get it on command line. I would just grep it and be eternally happy that I don't have to implement it Smile

It will be in next release.

suslik wrote:

We could even push miniupnp further into limelight; it is rather hard to find this gem behind the noise of Intel's stack usage.

Unrelated:
One interesting thing I noticed while polling my upnp devices from python yesterday. I recv() all responses, and on my network, there are 2: Linksys router and a Liinux-based wireless AP (upnp tag is "media server", passthrough, no NAT/masking).
If I poll with upnpc -s or -l, I see only Wireless AP (if I turn off Linksys's upnp) and only Linsys if its upnp is on.
Is one-device-only behavior just because upnpc is a simple example?

upnpc is using the FIRST IGD device found on the network that is connected.
On many networks, people have WinXP machines with network sharing enabled so It is needed to check if the IGD is connected.
Back to top
View user's profile Send private message Visit poster's website
suslik



Joined: 26 Apr 2007
Posts: 5
Location: Los Angeles

PostPosted: Wed May 02, 2007 3:00 pm    Post subject: Reply with quote

miniupnp wrote:
On many networks, people have WinXP machines with network sharing enabled so It is needed to check if the IGD is connected.


What I ended up doing in my (easier) case is look at the gateway entry assigned to the machine and only look at the "greeting" response from that IP. I just couldn't figure out how I can find out to which of the two IGDs the client machine is connected just by looking at uPnP responses. When I manually request the full device info, the LAN* device section is not there; just the WAN* devices.

suslik wrote:

On many networks, people have WinXP machines with network sharing enabled so It is needed to check if the IGD is connected.


For testing I slapped together some python. I use the httplib module to form the requests and get the answers back.

Adding and removing port mapping works, but
I have a strange problem with responses to GetGenericPortMappingEntry. I wrap the number of the entry with 'NewPortMappingIndex' but it always gives me the entry for #0 and 200, "OK". And sometimes I get this:

Code:

200 OK Connection: close
Server: Microsoft-Windows-NT/5.1 UPnP/1.0 UPnP-Device-Host/1.0
Content-length: 206
Content-Type: text/xml; charset="utf-8"

('<?xml version="1.0"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></SOAP-ENV:Body></SOAP-ENV:Envelope>', (200, 'OK'))


I only start getting the 'Out of Range' if I ask pass 2 'NewPortMappingIndex' argument in the request...

Rather strange. Your upnpc utility seems to get the whole list of mappings and I am guessing iterating GetGenericPortMappingEntry is the way you do it...

You are so right, uPnP is so much pain to wrangle. It looks rather simple on paper. So, yes, just relying on your util would be just fine for me, as long as I don't start getting threatening messages from users Smile
Back to top
View user's profile Send private message
suslik



Joined: 26 Apr 2007
Posts: 5
Location: Los Angeles

PostPosted: Mon May 07, 2007 12:01 pm    Post subject: python attempt at uPnP client Reply with quote

Just uploaded my python-based attempt at writing a uPnP client.

http://horovod.googlecode.com/svn/trunk/plugins/upnpclient.py

It can:
- getExternalIP
- add/delete Mapping (somewhat glitchy with some hard-assigned ports like 80, 25 on my Linksys. Likely Linksys router going nuts.)
- listMapping / poll details for particular port.

What is missing:
- need to provide client_machine and gateway_internal_ip to the lib upon activation. Detecting it otherwise is just too much work.
- enable / disable assigned port
- detection of which is active if both WANIPCon and WANPPPCon are both present. At this time defaults to the 1st that appears in the XML.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Thu Aug 30, 2007 11:00 pm    Post subject: Re: python attempt at uPnP client Reply with quote

suslik wrote:
Just uploaded my python-based attempt at writing a uPnP client.

http://horovod.googlecode.com/svn/trunk/plugins/upnpclient.py
[...]


miniupnpc now includes python bindings...
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> NAT/UPnP 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.