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 

a fix for windows

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Bugs
View previous topic :: View next topic  
Author Message
dolphinX



Joined: 05 Dec 2009
Posts: 2

PostPosted: Sat Dec 05, 2009 6:11 am    Post subject: a fix for windows Reply with quote

After I installed VMWare, miniupnp did't work. VMWare add 2 Virtual Ethernet Adapters into my system. I guess upnp would fail when the system had 2 or more adapters.
Here's the fix for Windows.

miniupnpc.c
add
Code:
#include <IPHlpApi.h>

for WIN32
in function upnpDiscover
at first
Code:
#ifndef WIN32

add else part
Code:
#else
MIB_IPFORWARDROW ip_forward;


and change
Code:
    sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);

to
Code:
#ifdef WIN32
   if ( GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) != NO_ERROR) return NULL;
   sockudp_w.sin_addr.s_addr = ip_forward.dwForwardNextHop;
#else
   sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
#endif
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1525

PostPosted: Mon Dec 07, 2009 12:24 pm    Post subject: Reply with quote

Thank you very much.
Only one question :
Why GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) and not GetBestRoute(inet_addr("239.255.255.250"), 0, &ip_forward) (UPNP_MCAST_ADDR)
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1525

PostPosted: Mon Dec 07, 2009 3:22 pm    Post subject: Reply with quote

also, what is the value is returned in ip_forward.dwForwardNextHop; ?
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
dolphinX



Joined: 05 Dec 2009
Posts: 2

PostPosted: Mon Dec 07, 2009 3:40 pm    Post subject: Reply with quote

Actually, this code is found from ACAT UPNP.
223.255.255.255 is the end address of class c ip.
I've test minutes ago that 239.255.255.250 is not work.

ip_forward.dwForwardNextHop on my pc is 0x0101a8c0 (192.168.1.1).

btw, GetBestRoute's Minimum supported client is Windows 2000.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1525

PostPosted: Thu Dec 10, 2009 9:55 pm    Post subject: Reply with quote

Hum I tested the code under Windows (vista) today and it didnt worked for me, so I reverted to the old code (which work)...
_________________
Main miniUPnP author.
http://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 -> miniupnpc Bugs 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.