Exemple #1
0
int WifiGecko_Send(const char * data, int datasize)
{
	if(WifiGecko_Connect() < 0)
		return connection;

	int ret = 0, done = 0, blocksize = 1024;

	while (done < datasize)
	{
		if(blocksize > datasize-done)
			blocksize = datasize-done;

		ret = net_send(connection, data+done, blocksize, 0);
		if (ret < 0)
		{
			WifiGecko_Close();
			return ret;
		}
		else if(ret == 0)
		{
			break;
		}

		done += ret;
		usleep (1000);
	}

	return ret;
}
int WifiGecko_Connect()
{
	return -1;
	if(connection >= 0)
		return connection;
	
	net_init();

	connection = net_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);

	if (connection < 0)
		return connection;

	struct sockaddr_in connect_addr;
	memset(&connect_addr, 0, sizeof(connect_addr));
	connect_addr.sin_family = AF_INET;
	connect_addr.sin_port = htons(portnumber);
	inet_aton(ipaddress, &connect_addr.sin_addr);

	if(net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
	{
		WifiGecko_Close();
		return -1;
	}

	return connection;
}
Exemple #3
0
int WifiGecko_Connect()
{
	if(connection >= 0)
		return connection;

	connection = net_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
	if (connection < 0)
		return connection;

	struct sockaddr_in connect_addr;
	memset(&connect_addr, 0, sizeof(connect_addr));
	connect_addr.sin_family = AF_INET;
	connect_addr.sin_port = htons(DESTINATION_PORT);
	inet_aton(DESTINATION_IP, &connect_addr.sin_addr);

	if(net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
	{
		WifiGecko_Close();
		return -1;
	}

	return connection;
}
Exemple #4
0
int main(int argc, char **argv)
{
	set_new_handler(no_memory);
	geckoinit = InitGecko();
	__exception_setreload(5);

	SYS_SetArena1Hi(APPLOADER_START);

	char *gameid = NULL;
	string dolLoc; //(argv[0] != NULL ? argv[0] : "");

	for (int i = 0; i < argc; i++)
	{
		if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
		{
			while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++;
			if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
				mainIOS = atoi(argv[i]);
		}
		else if (strlen(argv[i]) == 6)
		{
			gameid = argv[i];
			for (int i=0; i < 5; i++)
				if (!isalnum(gameid[i]))
					gameid = NULL;
		}
	}
	gprintf("Loading cIOS: %d\n", mainIOS);

	ISFS_Initialize();

	// Load Custom IOS
	bool iosOK = loadIOS(mainIOS, false);
	MEM2_init(52);

	u8 mainIOSBase = 0;
	iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase);
	gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);

	// Init video
	CVideo vid;
	vid.init();
	WIILIGHT_Init();
	vid.waitMessage(0.2f);

	// Init
	Sys_Init();
	Sys_ExitTo(EXIT_TO_HBC);

	int ret = 0;

	do
	{
		Open_Inputs();

		bool deviceAvailable = false;

		u8 timeout = 0;
		while(!deviceAvailable && timeout++ != 20)
		{
			DeviceHandler::Instance()->MountAll();
			sleep(1);

			for(u8 device = SD; device <= USB8; device++)
				if(DeviceHandler::Instance()->IsInserted(device))
					deviceAvailable = true;
		}

		bool dipOK = Disc_Init() >= 0;

		CMenu menu(vid);
		menu.init(dolLoc);
		mainMenu = &menu;
		if(!deviceAvailable)
		{
			menu.error(L"Could not find a device to save configuration files on!");
			break;
		}
		else if(!iosOK)
		{
			menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS));
			break;
		}
		else if(!dipOK)
		{
			menu.error(L"Could not initialize the DIP module!");
			break;
		}
		else
		{
			if (gameid != NULL && strlen(gameid) == 6)
				menu._directlaunch(gameid);
			else
				ret = menu.main();
		}
		vid.cleanup();
		if (bootHB)
		{
			IOS_ReloadIOS(58);
			BootHomebrew();
		}

	} while (ret == 1);

	WifiGecko_Close();

	Nand::Instance()->Disable_Emu();
	Nand::DestroyInstance();

	Sys_Exit();
	return 0;
};