int main(int argc, char **argv) { //irqInit(); irqEnable(IRQ_VBLANK); /* Setup logging console on top screen */ init_consoles(); print_to_debug("AirScan v1.0 by Raphael Rigo"); print_to_debug("released 07/11/2010"); print_to_debug(""); print_to_debug("B: Toggle OPN"); print_to_debug("A: Toggle WEP"); print_to_debug("X: Toggle WPA"); print_to_debug("Up/Down : scroll"); print_to_debug("Left/Right : Timeout -/+"); print_to_debug(""); print_to_debug("Initializing Wifi..."); Wifi_InitDefault(false); wardriving_loop(); return 0; }
int32_t SocketInit(int &sockDesc) { #ifdef __GNUWIN32__ WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) { return 0; } #endif #ifdef __NDS__ if ( !Wifi_InitDefault(WFC_CONNECT) ) { return 0; } if ( (sockDesc = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { return 0; } #elif defined (__GAMECUBE__) || defined (__WII__) if ( (sockDesc = net_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0 ) { return 0; } #else if ( (sockDesc = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0 ) { return 0; } #endif return 1; }
void enableNifi() { Wifi_InitDefault(false); // Wifi_SetPromiscuousMode: Allows the DS to enter or leave a "promsicuous" mode, in which // all data that can be received is forwarded to the arm9 for user processing. // Best used with Wifi_RawSetPacketHandler, to allow user code to use the data // (well, the lib won't use 'em, so they're just wasting CPU otherwise.) // int enable: 0 to disable promiscuous mode, nonzero to engage Wifi_SetPromiscuousMode(1); // Wifi_EnableWifi: Instructs the ARM7 to go into a basic "active" mode, not actually // associated to an AP, but actively receiving and potentially transmitting Wifi_EnableWifi(); // Wifi_RawSetPacketHandler: Set a handler to process all raw incoming packets // WifiPacketHandler wphfunc: Pointer to packet handler (see WifiPacketHandler definition for more info) Wifi_RawSetPacketHandler(packetHandler); // Wifi_SetChannel: If the wifi system is not connected or connecting to an access point, instruct // the chipset to change channel // int channel: the channel to change to, in the range of 1-13 Wifi_SetChannel(10); transferWaiting = false; nifiEnabled = true; }
void init_nds() { consoleDemoInit(); printf("yellhttptest\n"); printf("Initializing FAT...\n"); if(!fatInitDefault()) { printf("FAT init failed.\n"); console_pause(); } printf("Connecting via WFC data ...\n"); if(!Wifi_InitDefault(WFC_CONNECT)) { printf("Failed to connect!\nPress A to exit.\n"); console_pause(); } printf("Connected.\n"); }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- consoleDemoInit(); //setup the sub screen for printing iprintf("\n\n\tSimple Wifi Connection Demo\n\n"); iprintf("Connecting via WFC data ...\n"); if(!Wifi_InitDefault(WFC_CONNECT)) { iprintf("Failed to connect!"); } else { iprintf("Connected\n\n"); getHttp("www.akkit.org"); } while(1) { swiWaitForVBlank(); } return 0; }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- struct in_addr ip, gateway, mask, dns1, dns2; consoleDemoInit(); //setup the sub screen for printing iprintf("\n\n\tSimple Wifi Connection Demo\n\n"); iprintf("Connecting via WFC data ...\n"); if(!Wifi_InitDefault(WFC_CONNECT)) { iprintf("Failed to connect!"); } else { iprintf("Connected\n\n"); ip = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2); iprintf("ip : %s\n", inet_ntoa(ip) ); iprintf("gateway: %s\n", inet_ntoa(gateway) ); iprintf("mask : %s\n", inet_ntoa(mask) ); iprintf("dns1 : %s\n", inet_ntoa(dns1) ); iprintf("dns2 : %s\n", inet_ntoa(dns2) ); } while(1) { swiWaitForVBlank(); int keys = keysDown(); if(keys & KEY_START) break; } return 0; }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- Wifi_InitDefault(false); consoleDemoInit(); Keyboard* kb = keyboardDemoInit(); kb->OnKeyPressed = keyPressed; while(1) { int status = ASSOCSTATUS_DISCONNECTED; consoleClear(); consoleSetWindow(NULL, 0,0,32,24); Wifi_AccessPoint* ap = findAP(); consoleClear(); consoleSetWindow(NULL, 0,0,32,10); iprintf("Connecting to %s\n", ap->ssid); //this tells the wifi lib to use dhcp for everything Wifi_SetIP(0,0,0,0,0); char wepkey[64]; int wepmode = WEPMODE_NONE; if (ap->flags & WFLAG_APDATA_WEP) { iprintf("Enter Wep Key\n"); while (wepmode == WEPMODE_NONE) { scanf("%s",wepkey); if (strlen(wepkey)==13) { wepmode = WEPMODE_128BIT; } else if (strlen(wepkey) == 5) { wepmode = WEPMODE_40BIT; } else { iprintf("Invalid key!\n"); } } Wifi_ConnectAP(ap, wepmode, 0, (u8*)wepkey); } else { Wifi_ConnectAP(ap, WEPMODE_NONE, 0, 0); } consoleClear(); while(status != ASSOCSTATUS_ASSOCIATED && status != ASSOCSTATUS_CANNOTCONNECT) { status = Wifi_AssocStatus(); int len = strlen(ASSOCSTATUS_STRINGS[status]); iprintf("\x1b[0;0H\x1b[K"); iprintf("\x1b[0;%dH%s", (32-len)/2,ASSOCSTATUS_STRINGS[status]); scanKeys(); if(keysDown() & KEY_B) break; swiWaitForVBlank(); } char url[256]; if(status == ASSOCSTATUS_ASSOCIATED) { u32 ip = Wifi_GetIP(); iprintf("\nip: [%i.%i.%i.%i]\n", (ip ) & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF); while(1) { scanf("%s", url); if ( 0 == strcmp(url,"quit")) break; struct hostent *host = gethostbyname(url); if(host) iprintf("IP (%s) : %s\n", url, inet_ntoa(*(struct in_addr *)host->h_addr_list[0])); else iprintf("Could not resolve\n"); swiWaitForVBlank(); } } else {
int main(void) { aplist *head = NULL; aplist *cur; bool attached = true; // change this to false if you are only testing servos bool wifi_scan = true; // change this for emulator bool emulate = false; float pain = 0.9f; time_t update = 0; uint8 num; uint8 servo_pos = 0; uint8 current_servo = 1; unsigned char SERVO_PINS[3] = { SERVO_PIN1 ,SERVO_PIN2 ,SERVO_PIN3 } ; uint16 val[3] = { 0 }; uint8 i; touchPosition touch; videoSetMode(MODE_4_2D); vramSetBankA(VRAM_A_MAIN_BG); // set up our bitmap background bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0); decompress(cclogoBitmap, BG_GFX, LZ77Vram); // initialise lower screen for textoutput consoleDemoInit(); if (emulate == false) { iprintf("Initializing WiFi.. "); Wifi_InitDefault(false); while (Wifi_CheckInit() != 1) { } Wifi_ScanMode(); iprintf("done\n"); iprintf("Initializing DS brut.. "); uart_init(); uart_set_spi_rate(1000); iprintf("done\n\n\n"); iprintf("Using servo pins: %u %u %u\n\n", SERVO_PIN1, SERVO_PIN2, SERVO_PIN3); iprintf("Default pain multiplier: %.2f\n\n", pain); swiDelay(60000000); while (1) { scanKeys(); touchRead(&touch); if (keysDown() & KEY_X) { if (attached) { servo_detach(SERVO_PIN1); servo_detach(SERVO_PIN2); servo_detach(SERVO_PIN3); attached = false; } else { attached = true; } } if (keysDown() & KEY_A) { if (attached) { uint8 i = 0; for (i=0;i<3;i++) { servo_set(SERVO_PINS[i],0); } } //servo_set(SERVO_PIN1, 180-((rand() % 100)+(rand() % 50)+(rand() % 25))); //servo_set(SERVO_PIN2, 180-((rand() % 100)+(rand() % 50)+(rand() % 25))); //servo_set(SERVO_PIN3, 180-((rand() % 100)+(rand() % 50)+(rand() % 25))); } if (keysDown() & KEY_B) { if (wifi_scan == true) { wifi_scan = false; } else { wifi_scan = true; } } if (keysDown() & KEY_DOWN) { pain -= 0.1f; if (pain < 0.0f) { pain = 0.0f; } update = time(NULL); } if (keysDown() & KEY_UP) { pain += 0.1f; if (2.0f < pain) { pain = 2.0f; } update = time(NULL); } if (keysDown() & KEY_L) { current_servo += 1; if (current_servo > 3) { current_servo = 1; } } consoleClear(); if (wifi_scan == true) { num = 0; cur = head; iprintf("\n"); while (cur && num < 15) { // display if (!(cur->flags & 0x2)) { cur = cur->next; continue; } iprintf("%2u ", num); if (cur->ssid[0] == '\0') { iprintf("%02x%02x%02x%02x%02x%02x", cur->mac[0], cur->mac[1], cur->mac[2], cur->mac[3], cur->mac[4], cur->mac[5]); } else { iprintf("%s", cur->ssid); } iprintf(" @ %u", cur->rssi); if ((cur->flags & 0x06) == 0x06) { iprintf(" WPA"); } else if (cur->flags & 0x02) { iprintf(" WEP"); } // calculate servo commands if (attached && num < 3) { val[num] = (uint16)(cur->rssi*pain); if (180 < val[num]) { val[num] = 180; } iprintf(" %u", val[num]); } iprintf("\n"); if (num == 2) { iprintf ("\n"); } num++; cur = cur->next; } iprintf("\n"); if (time(NULL) < update+3) { printf("\npain multiplier: %.2f\n", pain); } // set the servo to zero if we don't have enough wifi nodes for (i=num; i<3; i++) { val[i] = 0; } if (attached) { servo_set(SERVO_PIN1, (uint8)val[0]); servo_set(SERVO_PIN2, 180-(uint8)val[1]); servo_set(SERVO_PIN3, (uint8)val[2]); } updateApList(&head, 0x00, NULL, NULL); sortApList(&head, false); } if (KEY_TOUCH && attached && !wifi_scan) { servo_pos = (touch.rawx / 3850.) * 180; iprintf ("servo pos x: %d;", servo_pos); iprintf ("\n"); servo_set(SERVO_PINS[current_servo-1],servo_pos); iprintf ("current servo: %d", current_servo); iprintf ("\n\n"); } swiWaitForVBlank(); } } while (1) { swiWaitForVBlank(); } return 0; }
int main(void) { struct in_addr ip, gateway, mask, dns1, dns2; // set the mode for 2 text layers and two extended background layers videoSetMode(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG_0x06000000); consoleDemoInit(); PrintConsole topScreen; PrintConsole bottomScreen; videoSetMode(MODE_0_2D); videoSetModeSub(MODE_0_2D); vramSetBankA(VRAM_A_MAIN_BG); vramSetBankC(VRAM_C_SUB_BG); consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true); consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true); consoleSelect(&bottomScreen); Keyboard *kbd = keyboardDemoInit(); kbd->OnKeyPressed = OnKeyPressed; consoleSelect(&topScreen); iprintf("Connecting to WiFi..."); if(!Wifi_InitDefault(WFC_CONNECT)){ iprintf("Failed to connect!"); exit(1); } iprintf("Connected\n\n"); uint16 keysPressed = ~(REG_KEYINPUT); if(keysPressed & KEY_A){ debug = true; } ip = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2); while(Connected == false && debug == false) { char wiiIP[256]; iprintf("Your ip: %s\n",inet_ntoa(ip)); iprintf("Type in your Wii's IP(or /cmd for the console):\n"); scanf("%s", wiiIP); if(!strcmp(wiiIP, "/cmd")){ CMD(); continue; } iprintf("\nConnecting To %s\nfrom %s...", wiiIP,inet_ntoa(ip)); int server = 0; server = TCP_ClientConnect(wiiIP, 8593);//TCP_ClientConnect(ip address, port) if(server == true){ Connected = true; iprintf("Connected\n"); } while(Connected == true){ } iprintf("Press start to exit or click any other button to try again:\n"); scanKeys(); while(!keysDown()){ scanKeys(); if(keysPressed & KEY_START) exit(0); } swiWaitForVBlank(); consoleClear(); } int host = 0; int client = 0; if(debug == true){ consoleClear(); iprintf("Welcome To Server Screen\n"); iprintf("Your ip: %s\n",inet_ntoa(ip)); host = TCP_Server(PORT, PLAYERS);//TCP_Server(port, number of players) } while(debug == true){ client = PLAYERS; client = TCP_GetClient(host);//TCP_GetClient(host socket) if(!clientForServer == 4){ clientForServer++; iprintf("Client connected(%d of %d)\n", clientForServer,PLAYERS); iprintf("Client id: %d\n", client); } } return 0; }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- initDisplay(); kprintf("dslink ... connecting ...\n"); if(!Wifi_InitDefault(WFC_CONNECT)) { kprintf(" Failed to connect!\n"); waitButtonA(); return 0; } struct in_addr ip, gateway, mask, dns1, dns2; ip = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2); kprintf("Connected: %s\n",inet_ntoa(ip)); int sock_udp = socket(PF_INET, SOCK_DGRAM, 0); struct sockaddr_in sa_udp, sa_udp_remote; sa_udp.sin_family = AF_INET; sa_udp.sin_addr.s_addr = INADDR_ANY; sa_udp.sin_port = htons(17491); if(bind(sock_udp, (struct sockaddr*) &sa_udp, sizeof(sa_udp)) < 0) { kprintf(" UDP socket error\n"); waitButtonA(); return 0; } struct sockaddr_in sa_tcp; sa_tcp.sin_addr.s_addr=INADDR_ANY; sa_tcp.sin_family=AF_INET; sa_tcp.sin_port=htons(17491); int sock_tcp=socket(AF_INET,SOCK_STREAM,0); bind(sock_tcp,(struct sockaddr *)&sa_tcp,sizeof(sa_tcp)); int i=1; ioctl(sock_tcp,FIONBIO,&i); ioctl(sock_udp,FIONBIO,&i); listen(sock_tcp,2); int dummy, sock_tcp_remote; char recvbuf[256]; while(1) { int len = recvfrom(sock_udp, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &sa_udp_remote, &dummy); if (len!=-1) { if (strncmp(recvbuf,"dsboot",strlen("dsboot")) == 0) { int respSock = socket(PF_INET, SOCK_DGRAM, 0); sa_udp_remote.sin_family=AF_INET; sa_udp_remote.sin_port=htons(17491); sendto(respSock, "bootds", strlen("bootds"), 0, (struct sockaddr*) &sa_udp_remote,sizeof(sa_udp_remote)); } } sock_tcp_remote = accept(sock_tcp,(struct sockaddr *)&sa_tcp,&dummy); if (sock_tcp_remote != -1) { loadNDS(sock_tcp_remote,sa_tcp.sin_addr.s_addr); closesocket(sock_tcp_remote); } swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_START) break; } return 0; }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- Wifi_InitDefault(false); consoleDemoInit(); //Keyboard* kb = keyboardDemoInit(); //kb->OnKeyPressed = keyPressed; while(1); { int status = ASSOCSTATUS_DISCONNECTED; consoleClear(); Wifi_AccessPoint* ap = findAP(); iprintf("Connecting to %s\n", ap->ssid); //this tells the wifi lib to use dhcp for everything Wifi_SetIP(0,0,0,0,0); Wifi_ConnectAP(ap, WEPMODE_NONE, 0, 0); while(status != ASSOCSTATUS_ASSOCIATED && status != ASSOCSTATUS_CANNOTCONNECT) { int oldStatus = status; status = Wifi_AssocStatus(); iprintf("%s", oldStatus != status ? ASSOCSTATUS_STRINGS[status] : "."); scanKeys(); if(keysDown() & KEY_B) break; swiWaitForVBlank(); } consoleClear(); consoleSetWindow(NULL, 0,0,32,10); char url[256]; if(status == ASSOCSTATUS_ASSOCIATED) { while(1) { u32 ip = Wifi_GetIP(); iprintf("ip: [%i.%i.%i.%i]", (ip ) & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, (ip >> 24) & 0xFF); scanf("%s", url); struct hostent *host = gethostbyname(url); if(host) iprintf("IP (%s) : %s\n", url, inet_ntoa(*(struct in_addr *)host->h_addr_list[0])); else iprintf("Could not resolve\n"); scanKeys(); if(keysDown() & KEY_B) break; swiWaitForVBlank(); } } } return 0; }
int wifi_init(void) { struct links *channel = CHANNELS + CHANNEL_WIFI; #ifdef _WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { confirm_error("WIFI: Error at WSAStartup()\n", 0); return DSH_CONNECTION_FAILED; } #else char readtext[33]; char iptext[33]; // ip address ONLY int ret, i, j, oldstatus; FILE *fp; unsigned char BUF[6]; iprintf("WIFI: Finding AP...\n"); fp = fopen("DallShell_Conf.txt","rb"); if(fp == NULL) { ret = Wifi_InitDefault(WFC_CONNECT); } else { Wifi_InitDefault(INIT_ONLY); Wifi_EnableWifi(); for(i=0;i<8;i++) { // DallShell Conf ���α����� txt���� ���, // �ԷµǴ� ���ڿ� �迭�� ũ�⸦ �÷��� (11.08.29) fgets(readtext,33,fp); memset(iptext,0,33); // iptext�� memory�ʱ�ȭ (11.08.29) switch(i){ case 0 : strcpy(ap.ssid,readtext); break; case 1 : ap.ssid_len = atoi(readtext); break; case 2 : ap.channel = atoi(readtext); break; case 3 : memcpy(iptext, readtext, strlen(readtext)-1); MyIP.s_addr = inet_addr(iptext); break; case 4 : memcpy(iptext, readtext, strlen(readtext)-1); gateway.s_addr = inet_addr(iptext); break; case 5 : memcpy(iptext, readtext, strlen(readtext)-1); mask.s_addr = inet_addr(iptext); break; case 6 : memcpy(iptext, readtext, strlen(readtext)-1); dns1.s_addr = inet_addr(iptext); break; case 7 : memcpy(iptext, readtext, strlen(readtext)-1); dns2.s_addr = inet_addr(iptext); break; } } ret = Wifi_ConnectAP(&ap,WEPMODE_NONE,0,0); } iprintf("MAC : "); Wifi_GetData(WIFIGETDATA_MACADDRESS, 6, BUF); for (i = 0; i < 6; i++) { iprintf("%02X", BUF[i]); if (i < 5) iprintf(":"); } iprintf("\n\n"); if(fp == NULL) { if(ret == 0) { confirm_error("WIFI:Failed to connect AP!\n", 0); return DSH_CONNECTION_FAILED; } iprintf("NULL"); MyIP = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2); } else { if(ret != -1) { iprintf("AP Connecting...\n"); while(j != ASSOCSTATUS_ASSOCIATED && j!= ASSOCSTATUS_CANNOTCONNECT) { oldstatus = j; j = Wifi_AssocStatus(); if(oldstatus != j) { iprintf("%s\n",ASSOCSTATUS_STRINGS[j]); if(j == ASSOCSTATUS_ASSOCIATED ) { Wifi_SetIP(MyIP.s_addr,gateway.s_addr,mask.s_addr,dns1.s_addr,dns2.s_addr); } } } } } iprintf("WIFI: Connected to AP\n"); // Mark that WIFI is available iprintf("IP : %s\n", inet_ntoa(MyIP)); iprintf("SVIP: %s\n", DOWNLOAD_IP); #endif channel->name = channel_name(CHANNEL_WIFI); channel->number =number_connect; // number connect channel->connect = wifi_connect; channel->read = wifi_read; channel->write = wifi_write; channel->disconnect = wifi_disconnect; channel->cleanup = wifi_cleanup; return 0; }