Welcome! Log In Create A New Profile

Advanced

Why isn't net_gethostip() in network.h?

Posted by iofthestorm 
Why isn't net_gethostip() in network.h?
January 12, 2009 07:17AM
Hi,
So I'm working on a network using program, intending to make an RSS reader, and I was reading some tutorials and looking at example code from other apps. I looked at ftpii's source, and I notice that he used the function net_gethostip() to get the ip address of the Wii. Then I looked in network.h and it wasn't there, which confused me. Finally I searched on Google Code search and found that it was actually in libogc in wii_network.c or something, but not in the network.h header, and that ftpii was using it by doing

extern u32 net_gethostip();

I know that extern is used to specify that the mentioned object is in another file, but why isn't that just in network.h? I'm new to C so forgive me if this question is something obvious.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 07:26AM
Blame bushing. He made a mistake. It's nothing more than that.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 07:26AM
No clue. If that works, go ahead and tell bushing or somebody about it, so they can add it to the GIT or CVS or whatever.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 07:33AM
Oh, ok. I was wondering what other fun hidden functions are in libogc, and was going to go read through the source. Actually, that might be a fun side project. It works fine, ftpii has been using it for a while I think and it worked in my program too. I'll pop into #wiidev and let him know I guess.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 11:26AM
Hi,

or you just could use if_config, which does the complete network init stuff for you and passes back the ip to you.

I added if_configex where you pass in a "struct in_addr". This is usefull if you need to use the hosts ip for binding a socket.
And yes, both functions, stuff the information into it. At the moment there's no way to manually configure your ip address.

Because network.h and if_config* is also used for the cube where you're able to manually configure all that. At the moment only the hosts ip is filled in. Also "use_dhcp" has to be true.

regrads
shagkur



Edited 2 time(s). Last edit at 01/12/2009 08:45PM by shagkur.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 07:39PM
Wow! I didn't even know what that did, although I did notice the similarity to ifconfig on Linux. I couldn't find any information about it in a quick Google search, as well as Google code search, and I don't think it's a standard socket function. Is there any place with documentation on libogc functions? The doxygen page was really out of data last I checked.

Edit:
So
s32 if_config( char *local_ip, char *netmask, char *gateway,boolean use_dhcp);
Are the char *local_ip *netmask and *gateway for me to pass in for manual configuration or will those be filled in by the proper values after if_config is done? And what does it do on error? I think I'll just look at the libogc source.

Oh, OK. So it returns 0 on successful initialization and stuffs the IP address in dotted form into *local_ip, and does nothing with the netmask and gateway? That's a bit misleading, although it is nice to have that handy function.



Edited 3 time(s). Last edit at 01/12/2009 07:48PM by iofthestorm.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 08:26PM
check wiiearth source at google code, it has pretty good cnad clear network code.
Re: Why isn't net_gethostip() in network.h?
January 12, 2009 09:22PM
Cool, that does have some very nice HTTP code. It doesn't explain how to use if_config though, and now I'm thinking it's best to use that to initialize, especially since shagkur recommended it. Mainly just to save on duplication of code. But I really like the WiiEarth code, especially the way it's commented and functions are named logically and everything. Very useful as a reference. But I don't want to use it directly because it's best if I learn everything myself, so when something goes wrong I know how to fix it.
Sorry, only registered users may post in this forum.

Click here to login