DNS Lookup February 24, 2009 06:25PM | Registered: 15 years ago Posts: 25 |
// Simple little DNS lookup program - C #include network.h #include stdio.h #include string.h #include stdlib.h #include unistd.h #include gccore.h #include wiiuse/wpad.h static void *xfb = NULL; static GXRModeObj *rmode = NULL; //--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Standard console initialisation procedures VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); printf("\x1b[2;0H"); // The Actual Connection bit, effectively copied wholesale from WiiEarth source char *domain = "forum.wiibrew.org"; // The example domain to look up struct hostent *host = net_gethostbyname(domain); // Retrieve the host information if(host == NULL) { // Test for failure printf("Failed to retrieve domain %s\n", domain); }else { u32 *ip = (u32*)host->h_addr_list[0]; // creates a reference to the IP printf("Domain \"%s\"'s IP address: %u",domain,ip); // Print the output } // Your standard "Wait until you press home to quit" loop while(1) { WPAD_ScanPads(); u32 pressed = WPAD_ButtonsDown(0); if ( pressed & WPAD_BUTTON_HOME ) { exit(0); } VIDEO_WaitVSync(); } return 0; }
Re: DNS Lookup February 24, 2009 07:36PM | Registered: 15 years ago Posts: 703 |
char localip[16]; char gateway[16]; char netmask[16]; s32 ret = if_config ( localip, netmask, gateway, TRUE); if (ret>=0) { printf ("network configured, ip: %s, gw: %s, mask %s\n", localip, gateway, netmask); }else{ printf("Fail"); }
Re: DNS Lookup February 24, 2009 09:07PM | Registered: 15 years ago Posts: 25 |
Re: DNS Lookup February 25, 2009 11:29AM | Registered: 16 years ago Posts: 265 |