Great Project, Super useful

Jan 3, 2008 at 4:17 PM
I was trying to programmatically port forward in C# a while ago and searched far n wide for complete UPNP Nat Device implementation.
I never really needed the complete NatDevice service, just port mapping.
Thanks so much for writing this!

If you want to give me some guidance on how to extend this with more NATDevice services, I'd be happy to contribute.

-Vijay
Coordinator
Jan 9, 2008 at 9:02 AM
Edited Jan 14, 2008 at 9:04 PM
Hi!

I'm happy you have found interesting my project.!

At this moment, I'm working on parsing the SOAP response from the NATDevice. Next I need to implement the actual code to remove a port mapping and get the external address of the device. If you want to collaborate to this task, you are welcome!

--
Marco Minerva, marco.minerva@gmail.com
http://blogs.ugidotnet.org/marcom
Jan 14, 2008 at 1:30 AM
Hi,

I looked at using the NATUPNP COM Type libraries that comes with XP over the weekend, but I couldn't work out how to actually get a list of found NAT Devices. COM confuses me, and the API is poorly documented.

It's probably a better idea to stick with string constants, string formats and maybe SOAP serialization in .NET.

How are you implementing the SOAP response parser? I'm not sure how SOAP request/response works, but when I print out the response from the GetExternalIPAddress method I don't get back any useful information. How do u make a request for the information? Are SOAP responses returned through a callback URL, or am I reading the wrong response?

-Vijay
Coordinator
Jan 14, 2008 at 9:02 PM
Hi!

I too have tried the NATUPNP COM Library, but I haven't managed to make it works correctly: sometimes it runs fine, other times it throws strange errors...

A few minutes ago I have uploaded a new change-set of the SharpUpnp library. The SOAP parser I have implemented is really simple: when a response is received, I check if the the message contains a tag named "<Method>Response", where <Method> is the Upnp method I have invoked (AddPortMapping, DeletePortMapping, GetExternalIPAddress, ecc.): if this node exists, its inner text is the response message, if any. For example, the inner text of GetExternalIPAddressResponse is the actual public IP address of the NAT device. Watch the UpnpNatDevice.SendRequest method to discover how I have realized the request/response message exchange. And, as always, let me know if you have any other questions :-)

--
Marco Minerva, marco.minerva@gmail.com
http://blogs.ugidotnet.org/marcom