MCPcopy Create free account
hub / github.com/devkitPro/3ds-hbmenu / netloaderTask

Function netloaderTask

source/ui/netloader.c:247–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void netloaderTask(void* arg)
248{
249 struct sockaddr_in sa_udp_remote;
250 char recvbuf[256];
251 wantExit = false;
252 filelen = 0;
253 filetotal = 0;
254
255 if (!netloaderInit())
256 {
257 errorScreen(textGetString(StrId_NetLoader), textGetString(StrId_NetLoaderUnavailable));
258 return;
259 }
260
261 uiEnterState(UI_STATE_NETLOADER);
262
263 if (!netloaderActivate())
264 {
265 netloaderDeactivate();
266 uiExitState();
267 return;
268 }
269
270 while (datafd < 0)
271 {
272 if (wantExit)
273 {
274 netloaderDeactivate();
275 uiExitState();
276 return;
277 }
278
279 socklen_t fromlen = sizeof(sa_udp_remote);
280
281 int len = recvfrom(udpfd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &sa_udp_remote, &fromlen);
282 if (len != -1 && strncmp(recvbuf, "3dsboot", 7) == 0)
283 {
284 sa_udp_remote.sin_family = AF_INET;
285 sa_udp_remote.sin_port = htons(NETWORK_PORT);
286 sendto(udpfd, "boot3ds", 7, 0, (struct sockaddr*) &sa_udp_remote,sizeof(sa_udp_remote));
287 }
288
289 socklen_t addrlen = sizeof(struct sockaddr_in);
290 datafd = accept(listenfd, (struct sockaddr*)&sa_udp_remote, &addrlen);
291 if (datafd < 0)
292 {
293 if (errno != -EWOULDBLOCK && errno != EWOULDBLOCK)
294 {
295 netloaderError("accept", errno);
296 return;
297 }
298 } else
299 {
300 close(listenfd);
301 listenfd = -1;
302 }
303
304 svcSleepThread(16666666ULL);

Callers

nothing calls this directly

Calls 13

netloaderInitFunction · 0.85
errorScreenFunction · 0.85
textGetStringFunction · 0.85
uiEnterStateFunction · 0.85
netloaderActivateFunction · 0.85
netloaderDeactivateFunction · 0.85
uiExitStateFunction · 0.85
netloaderErrorFunction · 0.85
recvallFunction · 0.85
menuEntryInitFunction · 0.85
receiveAndDecompressFunction · 0.85
launchAddArgFunction · 0.85

Tested by

no test coverage detected